Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7955665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:45:55+00:00 2026-06-04T03:45:55+00:00

Can I get some help with the following code? $(document).ready(function() { $(‘#searchform’).submit(function() { var

  • 0

Can I get some help with the following 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 = '<?php get_bloginfo('url') ?>';
            $("#s").attr('name','s');
        }

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

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

});

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:

$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>';

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:45:57+00:00Added an answer on June 4, 2026 at 3:45 am

    The line in your JS:

    action = '<?php get_bloginfo('url') ?>';
    

    isn’t going to work. <?php ?> tags a executed server side. JS code is executed in the browser.

    You will need to specify the form’s action url explicity: Similar to:

    action = 'http://catalog.site.com/uhtbin/cgisirsi.exe/x/0/0/57/5';
    

    I suggest that you create a hidden field:

    $search_form .= '<input id="blog_url" type="hidden" value="' . get_bloginfo('url'). '">';
    

    Your JS can then reference this browser side:

    action = $('#blog_url').val();
    

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like some help with the following jQuery code if possible... $(document).ready(function() { $('table.sortable').each(function()
I am curious if I can get some help with Open Graph since I
Hi and good evening, hope someone can help. I am trying to get some
I am stuck with some TouchXML code. Please help. I have the following code
I need some help with the following code... How do I create the array
Can I get some help posting across different pages from a custom control? I've
this is a bit of a newbie question but hoping I can get some
how can i get some part of string (in symbols). For example: $string =
How can I get some part of string that I need? accountid=xxxxxx type=prem servertime=1256876305
Where can I get some explanations on what F1 , F2 , F3 ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.