View Full Version : passing search form variable to a url

06-15-2007, 01:12 PM
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


the output i need is


ive tried varing combinations but am getting nowhere

thanks to anyone who can help :)

06-15-2007, 02:58 PM
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>

06-18-2007, 05:55 PM
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

06-18-2007, 06:06 PM
Post the code for getMarks().

06-18-2007, 06:15 PM
you sure! ? :)


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");
gmarkers = [];
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);

what getmarks does is grab the xml thats created by the marks.php file

ie from this in the php file

$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

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 :)

06-18-2007, 06:28 PM
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.

<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" />

06-18-2007, 07:01 PM
top man - ive been trying to sort this out for a few days

thanks :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum