您好我在mangeto网站上有一个搜索表单,http://upgrade.fisapacient.ro它看起来像这样:
<form id="search_mini_form">
<div class="form-search">
<label for="search">Search:</label>
<div class="input-box"><input id="search" type="text" name="q" value="" class="input-text" autocomplete="off" lang="ro"></div>
<button type="submit" title="Cauta" class="button"><span><span>Cauta</span></span></button>
<div id="search_autocomplete" class="search-autocomplete" style="display: none; "></div>
<input name="SE" type="radio" value="catalogsearch/result/">Produse
<input name="SE" type="radio" value="cauta">Site
<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form', 'search', 'Cauta in magazin...');
searchForm.initAutocomplete('http://upgrade.fisapacient.ro/catalogsearch/ajax/suggest/', 'search_autocomplete');
//]]>
</script>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
j("#search_mini_form").change(function() {
var action = j(this).val() == "Produse" : "Site";
j("#search_mini_form").attr("action",action);
});
//]]>
</script>
如果选中“Produse”收音机,它应该将表格动作更改为“catalogsearch / result /”,如果选中“Site”收音机,则将表格操作更改为“cauta”,我将通过以下代码获得以下结果: 当我点击“Produse”时,我得到“http://upgrade.fisapacient.ro/?q=test+search&SE=catalogsearch%2Fresult%2F” 当我点击“网站”时,我得到“http://upgrade.fisapacient.ro/?q=test+search&SE=cauta” 我需要它像“产品”和“http://upgrade.fisapacient.ro/cauta?q=test”这样的“http://upgrade.fisapacient.ro/catalogsearch/result/?q=test%20query” %20query“for”Site“。
答案 0 :(得分:1)
jQuery("#search_mini_form input[type='radio']").change(function() {
var action = jQuery(this).val();
jQuery("#search_mini_form").attr("action",action);
});
jQuery("#search_mini_form").submit(function() {
jQuery("input[type='radio']", this).attr('disabled', 'disabled');
});