0

所以我将此代码放入搜索表单中:

<select name="rentbuy">
<option value="buy">Buy</option>
<option value="rent">Rent</option>
<option value="rent/week">Rent/week</option>
</select>

这就是我想要做的:

<select name="rentbuy">
<option value="buy">Buy</option>
<option value="rent rent/week">Rent</option>
</select>

因此,当有人选择“租金”时,我希望表格同时获得“租金”和“租金/周”的值。

谢谢。

4

2 回答 2

0

在选择元素上使用多个属性:

<select name="rentbuy" multiple="multiple">
 <option value="buy">Buy</option>
 <option value="rent" selected="selected">Rent</option>
 <option value="rent/week"  selected="selected">Rent/week</option>
</select>

这是一个jsfiddle:http: //jsfiddle.net/v2wHS/

于 2013-10-18T09:44:57.200 回答
0

我将这段代码放入主题中,也许对某些事情有帮助:

$search_buyorrent = "";
if (get_option('wp_search_bor') == "Yes") {
if (isset($_COOKIE['rentbuy']) && $_COOKIE['rentbuy'] != '') {
$search_buyorrent = $_COOKIE['rentbuy'];
} else {
if (isset($_POST['rentbuy'])) {
$search_buyorrent = trim($_POST['rentbuy']);
}
}
} else {
$search_buyorrent = '';
}

这里还有另一个片段:

if ($search_buyorrent == "buy" || $search_buyorrent == "") {
$query ="SELECT p.* FROM $wpdb->posts p, $wpdb->postmeta p1
WHERE p.ID = p1.post_id AND p1.meta_key='price_value' AND convert(p1.meta_value,        signed) BETWEEN '$search_pricemin_buy' AND '$search_pricemax_buy'";
$spm = getIds( $query );
$_ids = ( !empty($spm) ? ( !empty($_ids) ? array_intersect( $_ids, $spm) : "" ) : "" );
}
于 2013-10-18T10:08:27.127 回答