次のコードについて助けを得ることができますか?
$(document).ready(function() {
$('#searchform').submit(function() {
var action = '';
if($('.action_url').val() == 'l_catalog') {
action = 'http://catalog.site.com/uhtbin/cgisirsi.exe/x/0/0/57/5';
$("#s").attr('name','searchdata1');
} else if ($('.action_url').val() == 'l_wordpress'){
action = '<?php get_bloginfo('url') ?>';
$("#s").attr('name','s');
}
$(this).attr('action', action);
return true; // submit
});
$('.action_url').change();
});
この関数を使用して、フォームのアクションをライブラリ カタログ検索ページまたはワードプレス検索ページのいずれかに設定しようとしています。現在、ラジオ ボタンは選択/選択解除し、wordpress ではなくカタログのみを検索します。私はもともとこのコードを選択フォーム用にオンラインで見つけていましたが、現在はラジオボタンを使用する必要があります。(いくつかの困難があります)。このための PHP は次のとおりです。
$search_form .= '<form id="searchform" name="searchform" method="get" action="' . get_bloginfo('url') .'/">';
$search_form .= "\n" . "\t" . "\t";
$search_form .= '<div>';
$search_form .= "\n" . "\t" . "\t". "\t";
$search_form .= '<input type="radio" name="search_where" id="catalog" class="action_url" value="l_catalog" /> <label for="catalog">Library Catalog</label> <input type="radio" name="search_where" id="wordpress" class="action_url" value="l_wordpress" /> <label for="wordpress">Library Website</label>'; // <option value=\"l_catalog\">Library Catalog</option> \n \t \t \t \t <option value=\"l_wordpress\">Library Website</option>";
$search_form .= "\n" . "\t" . "\t". "\t";
if (is_search()) {
$search_form .= '<input id="s" name="searchdata1" type="text" value="' . esc_html(stripslashes($_GET['s'])) .'" size="' . $search_form_length . '" tabindex="1" />';
} else {
$value = __('To search, type and hit enter', 'thematic');
$value = apply_filters('search_field_value',$value);
$search_form .= '<input id="s" name="searchdata1" type="text" value="' . $value . '" onfocus="if (this.value == \'' . $value . '\') {this.value = \'\';}" onblur="if (this.value == \'\') {this.value = \'' . $value . '\';}" size="'. $search_form_length .'" tabindex="1" />';
}
$search_form .= "\n" . "\t" . "\t". "\t";
$search_form .= '<input name="srchfield1" type="hidden" value="GENERAL^SUBJECT^GENERAL^^words or phrase">';
$search_form .= '<input name="sort_by" type="hidden" value="-PBYR">';
$search_form .= '<input name="user_id" type="hidden" value="WSC">';
$search_form .= '<input name="password" type="hidden" value="">';
$search_form .= "\n" . "\t" . "\t". "\t";
$search_submit = '<input id="searchsubmit" name="searchsubmit" type="submit" value="' . __('Search', 'thematic') . '" tabindex="2" />';
$search_form .= apply_filters('thematic_search_submit', $search_submit);
$search_form .= "\n" . "\t" . "\t";
$search_form .= '</div>';
$search_form .= "\n" . "\t";
$search_form .= '</form>';
私は PHP や Javascript をよく知らず、ビッグ リーグでプレーしようとしているので、これは面倒だと思います。