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 8881209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:17:55+00:00 2026-06-14T20:17:55+00:00

I have a search function that will accept a search string and send it

  • 0

I have a search function that will accept a search string and send it to a php file for parsing a database column. I’d also like users to choose which aspect of the website they’d like to search (comics, artwork, or both). Comic and Artwork or stored in two separate tables.

This is a function that will accept an input search string from the html below and send it to a php file.

<script type="text/javascript">

        function search(searchString) {     
            //var site = $("#site").val();
            $.get("./scripts/search.php", {_input : searchString},
                function(returned_data) {
                    $("#output").html(returned_data);
                }
            );
        }

And this is javascript to accept a choice to search “comics”, “artwork” or “all”.

        function searchChoice(choice) {     
            alert("Choice: " + choice);
            $.get("./scripts/search.php", {_choice : choice}
           );
        }

</script>

HTML:

    <!--Search filtering for comics, artwork, or both-->
<span class="search"><b>Search for: </b> </span>

<div class="btn-group" data-toggle="buttons-radio">
<span class="search">
    <button type="button" class="btn" id="comics" onclick="searchChoice(this.id)">Comics</button> 
    <button type="button" class="btn" id="artwork" onclick="searchChoice(this.id)">Artwork</button> 
    <button type="button" class="btn" id="all" onclick="searchChoice(this.id)">All</button> 
</span>
</div>

<br/>
<br/>

<!--Search functionality-->
<span class="search">
    <input type="text" onkeyup="search(this.value)" name="input" value="" />
</span>

<br />
<span id="output"><span class="sidebarimages">  </span></span>

PHP excerpt:

$input = (isset($_GET['_input']) ? ($_GET['_input']) : 0); 
$siteChoice = (isset($_GET['_choice']) ? ($_GET['_choice']) : "all");

You can see the javascript correctly alerting out “Choice: comics” when comics button is selected, but the php side, echo "</br>Choice: " . $siteChoice;, is echo’ing out “all”, which is incorrect.

enter image description here

Any ideas would be greatly appreciated!

  • 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-14T20:17:56+00:00Added an answer on June 14, 2026 at 8:17 pm

    As mentioned @E_p, that is the problem … another option is to create a variable and store the data there … try this: you don’t need change the html

       var mySearchString = 0;
       var myChoice = 'all';
    
    
    function search(searchString) {     
            mySearchString = searchString;
            GetSearch();
            }
    
    function searchChoice(choice) {     
                myChoice = choice;
                GetSearch();
                }
    
    function GetSearch(){
    
     $.get("./scripts/search.php", {_input : mySearchString, _choice : myChoice},
            function(returned_data) {
                $("#output").html(returned_data);
            }
        );
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a binary search function that will search for a word in an
I have a function that searches for a string inside a text file. I
I am trying to create a function that will split a string into search
I'm trying to write a function that will (1) search a given file for
I would like to add a feature to my search function that will execute
hello i have a search function in that i will search a db for
I have a for loop in a search function, with a function that does
I have a function that uses Pattern#compile and a Matcher to search a list
I have a search function in my project. In the searchable.xml, i would like
I have created a Google Search function, however I would like to leave the

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.