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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

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

Post 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.
Last edited by jonas on Thu Jun 10, 2004 2:31 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

using Javascript, you could process the 'go' onclick/onchange events to change the href, instead of "submitting" it..
jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

Post by jonas »

I do not know Javascript very well, what should I search for?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

Post 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?
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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>
jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

Post 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.
jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

Post 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)
jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

Post 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! :)
Post Reply