Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ajax event problem

    Hi All,
    Please excuse my ignorance. This is my first ever bit of DOM/JavaScript coding...

    I am modifying an Ajax livesearch script. At the moment it correctly passes $q to the PHP search script, but does not pass $submitted or $database unless the user hits submit.

    I would like to offer the ability to search a specific database ($database) so the value of the select gets passed across to the script. Unfortunately, I haven't the foggiest idea how to do this.

    Any ideas/pointers would be extremely grateful!

    Many thanks!



    <form action="livesearch_results.php" method="GET" target="searchWindow">
    <input type="hidden" name="submitted" value="submit"/>

    <input type="text" name="q" id="q" size="15" onkeyup="loadXMLDoc('livesearch_results.php?q='+this.value)" style="width:250px; " />


    <select name="database">
    <option value="news">in news</option>
    <option value="articles">in articles</option>
    <option value="glossary">in glossary</option>
    <option value="directory">in shop finder</option>
    <option value="backissues">in back issues</option>
    </select>

  • #2
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <input type="text" name="q" id="q" size="15" onkeyup="loadXMLDoc('livesearch_results.php?q='+this.value)" style="width:250px; " />
    would become
    <input type="text" name="q" id="q" size="15" onkeyup="buildParamList(this);" style="width:250px; " />

    Code:
    function buildParamList(obj)
    {
    var url = 'livesearch_results.php?q=' + obj.value;
    var db = "&database=' + document.getElementById('database').value;
    
    loadXMLDoc(url)
    }
    You need to ad the id tag to the database select control.

    This is just a general idea of how you could do it, hope it helps.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •