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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    passing search form variable to a url

    my search of a mysql database is getMarks(blah.php?name=whateverthemarkernameis)

    so far ive got to this

    <form method="get" onsubmit="getMarks(); return false">
    <input type="text" name="marks.php?name=" id="name" value="clubs" />
    <input align="left" type="submit" value="" /> </form>

    which outputs

    http://www.blah.com/?marks.php%3Fnam...ver_was_typed#

    the output i need is

    www.blah.com/marks.php?name=whatever_was_typed

    ive tried varing combinations but am getting nowhere

    thanks to anyone who can help

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Your form is wrong

    <form method="get" action="marks.php" onsubmit="getMarks(); return false">
    <input type="text" name="name" id="name" value="clubs" />
    <input align="left" type="submit" value="submit" name="btnSubmit"/> </form>
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that doesnt work

    the form i'm using in a menu system is this:

    <input type="button" value="Bars" onclick='getMarks("marks.php?name=bars")'; action="get" class=mapbutton>

    which works great - but obviously i start with a known variable

    but this:

    <form method="get" action="marks.php?" onsubmit="getMarks()">
    <input type="text" name="marks.php?name" id="name" value="seach" />
    <input align="left" type="submit" value="submit" /></form>

    works but doesnt invoke the getMarks function and just returns the result of the db query

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Post the code for getMarks().
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you sure! ?

    ok

    Code:
    function getMarks(url) {
    var bounds = new GLatLngBounds();
    var request = GXmlHttp.create(); 
    request.open("GET", url, true);
    request.onreadystatechange = function() {
    if (request.readyState == 4) {	
    var xmlDoc = request.responseXML;
    var markers = xmlDoc.documentElement.getElementsByTagName("marker");
    map.getInfoWindow().hide();
    map.clearOverlays();
    gmarkers = [];
    side_bar_html="";
    for (var loop1=0;loop1<markers.length;loop1++){
    var lat = parseFloat(markers[loop1].getAttribute("lat"));  
    var lng = parseFloat(markers[loop1].getAttribute("lng")); 
    var point = new GLatLng(lat,lng);
    *snip*
    what getmarks does is grab the xml thats created by the marks.php file

    ie from this in the php file
    Code:
    $query = "SELECT lat, lng, html, label, icontype FROM blah WHERE icontype='" . $_GET['name'] . "' OR town='" . $_GET['name'] . "'";
    i then use this to create the xml

    Code:
     echo "<markers>";
     while ($row=mysql_fetch_assoc($query)){
    echo '<marker  lat="'.$row['lat'].'" lng="'.$row['lng'].'" html="'.parseToXML($row['html']).'" label="'.$row['label'].'" icontype="'. $row['icontype'].'"/>'; 
     }
     echo "</markers>";

    if this makes sense

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You need to return false to the onsubmit handler since you are not doing a normal form submission; you are doing an AJAX request. If Javascript is disabled or not supported, the form will be submitted normally and will output XML to the browser.
    Code:
    <form method="get" action="marks.php" onsubmit="getMarks(this.action+'?name='+escape(this.name.value)); return false;">
    <input type="text" name="name" value="" />
    <input type="submit" value="submit" name="btnSubmit" /> 
    </form>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    top man - ive been trying to sort this out for a few days

    thanks


  •  

    Posting Permissions

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