Page 1 of 1

[SOLVED] Restricting the X and Y from Image Submit buttons..

Posted: Wed Jun 09, 2004 3:03 pm
by jonas
Well, maybe this isn't that easy but anyways...

http://www.bolt3.com/systems.php

This is part of my site I'm working on. Go to this page and use my system drop down menu to pick a system and hit the go button.
In the URL bar, it passes the systemID and then the variables for the go button aswell. Thing is I do not want the variables from the submit button to be passed (&Submit.x=3&Submit.y=11).
I just want users to see http://www.bolt3.com/systems.php?systemID=15 (an example)....

So is there a way to get rid of the submit button junk it's passing? I want to leave my urls as clean as can be for now so when I install the mod_rewrite it wont be all wierd.

Thanks guys.

Posted: Wed Jun 09, 2004 3:16 pm
by feyd
using Javascript, you could process the 'go' onclick/onchange events to change the href, instead of "submitting" it..

Posted: Wed Jun 09, 2004 3:23 pm
by jonas
I do not know Javascript very well, what should I search for?

Posted: Wed Jun 09, 2004 3:28 pm
by feyd
first, lets try something simple: remove the name of the submit image. I don't quite remember whether or not it'd pass data if it didn't have a name..

Posted: Wed Jun 09, 2004 3:32 pm
by jonas
http://www.bolt3.com/systems.php?systemID=4&x=13&y=7

So now we get x and y ...

I suppose this is because it is an image submit button over a regular browser submit button?

Posted: Wed Jun 09, 2004 4:53 pm
by mjseaden
Have you considered using method 'POST'? Otherwise your submit button will just dump all of the data into the URL, and as you say it looks messy.

Posted: Wed Jun 09, 2004 5:10 pm
by feyd
okay.. since that's not quite right.. Try this:

Code: Select all

<script language="Javascript"><!--
function buildSearch(go)
&#123;
document.location.href = go;
return false;
&#125;
//--></script>

--------

<form name="whatever" onsubmit="buildSearch(this.systemID.options&#1111;this.systemID.selectedIndex].value)"><select name="systemID" onchange="buildSearch(this.options&#1111;this.selectedIndex].value)">
<option>---------</option>
<option value="http://someurl.com">some option</option>
</select><input type="image" src="someimage.gif"></form>

Posted: Thu Jun 10, 2004 11:05 am
by jonas
mjseaden: no, because I want them to be able to see the systemID... that way they can bookmark it and such. I don't want them to see the x and y gibberish that is there.

I'll try that feyd.

Posted: Thu Jun 10, 2004 11:22 am
by jonas
I don't think I'm doing this right.....

Code: Select all

<script language="Javascript"><!-- 
function buildSearch(go) 
&#123; 
document.location.href = go; 
return false; 
&#125; 
//--></script> 




<form onsubmit="buildSearch(this.systemID.options&#1111;this.systemID.selectedIndex].value)" method="GET">
		<tr>
		<td><select name="system_ID" class="headerform" onchange="buildSearch(this.options&#1111;this.selectedIndex].value)"> 
		<option value="" selected>Pick a System</option>");
		$query = "SELECT * FROM systems";
		$mysql_stuff = mysql_query($query, $mysql_link);
		while($roc = mysql_fetch_row($mysql_stuff))&#123;
			$system_ID = $roc&#1111;0];
			$system_name = $roc&#1111;1];
			print("<option value="http://www.bolt3.com/systems.php">$system_name</option>");
		&#125;
		print("</select></td>
		<td valign="middle"><input type="image" src="http://www.bolt3.com/siteimages/gobutton.gif"></td>
I just noticed that my search bar to the left also submits (even though it goes to no where currently) the x and y values of the image submit.

I notice a lot of big sites use the same method of passing variables as I do but they don't have the x and y values pass.(rottentomatoes.com)

Posted: Thu Jun 10, 2004 12:10 pm
by jonas
Found a fix!
Easy as pie! Check it out:
<a href="javascript:document.formName.submit()" onMouseOver="status=''; return true"><img src=myImage></a>


Works like a charm

EDIT: added the status bar = nothing change.. dont want users peeking into my code! :)