Change Form Action and Text Input Name based on Radio Input Checked
<p>Can I get some help with the following code?</p>

<pre><code>$(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 = '&lt;?php get_bloginfo('url') ?&gt;';
            $("#s").attr('name','s');
        }

        $(this).attr('action', action);
        return true; // submit
    });

    $('.action_url').change();

});
</code></pre>

<p>I'm trying to use this function to set the action of a form to either a library catalog search page or the wordpress search page. Currently the radio buttons will select/deselect and will search the catalog only and not the wordpress. I had originally found this code online for a select form but now have to use radio buttons. (Having some difficulties). The PHP for this is:</p>

<pre><code>$search_form .= '&lt;form id="searchform" name="searchform" method="get" action="' . get_bloginfo('url') .'/"&gt;';
$search_form .= "\n" . "\t" . "\t";
$search_form .= '&lt;div&gt;';
$search_form .= "\n" . "\t" . "\t". "\t";
$search_form .= '&lt;input type="radio" name="search_where" id="catalog" class="action_url" value="l_catalog" /&gt; &lt;label for="catalog"&gt;Library Catalog&lt;/label&gt; &lt;input type="radio" name="search_where" id="wordpress" class="action_url" value="l_wordpress" /&gt; &lt;label for="wordpress"&gt;Library Website&lt;/label&gt;'; // &lt;option value=\"l_catalog\"&gt;Library Catalog&lt;/option&gt; \n \t \t \t \t &lt;option value=\"l_wordpress\"&gt;Library Website&lt;/option&gt;";
$search_form .= "\n" . "\t" . "\t". "\t";
if (is_search()) {
        $search_form .= '&lt;input id="s" name="searchdata1" type="text" value="' . esc_html(stripslashes($_GET['s'])) .'" size="' . $search_form_length . '" tabindex="1" /&gt;';
} else {
        $value = __('To search, type and hit enter', 'thematic');
        $value = apply_filters('search_field_value',$value);
        $search_form .= '&lt;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" /&gt;';
}
$search_form .= "\n" . "\t" . "\t". "\t";

$search_form .= '&lt;input name="srchfield1" type="hidden" value="GENERAL^SUBJECT^GENERAL^^words or phrase"&gt;';
$search_form .= '&lt;input name="sort_by" type="hidden" value="-PBYR"&gt;';
$search_form .= '&lt;input name="user_id" type="hidden" value="WSC"&gt;';
$search_form .= '&lt;input name="password" type="hidden" value=""&gt;';

$search_form .= "\n" . "\t" . "\t". "\t";

$search_submit = '&lt;input id="searchsubmit" name="searchsubmit" type="submit" value="' . __('Search', 'thematic') . '" tabindex="2" /&gt;';

$search_form .= apply_filters('thematic_search_submit', $search_submit);

$search_form .= "\n" . "\t" . "\t";
$search_form .= '&lt;/div&gt;';

$search_form .= "\n" . "\t";
$search_form .= '&lt;/form&gt;';
</code></pre>

<p>I'm sure this is messy, since I don't know PHP or Javascript very well and I'm trying to play in the Big League.</p>
