phpretard
asked on
How can I submit a form by pressing enter and using an image as the submit type?
I have form using an image as a submit button.
It won't submit when I press enter...only if I click the button.
This may not be a PHP help but I figured I throw it out here and see if anyone could point me in the right direction.
I've been all over Google and the only reference I could find was standard type='submit'.
It won't submit when I press enter...only if I click the button.
This may not be a PHP help but I figured I throw it out here and see if anyone could point me in the right direction.
I've been all over Google and the only reference I could find was standard type='submit'.
if (isset($_POST['MainSearch_y'])){
execute code
}
ASKER
This is what I have and it doesn't seem to work...
Any thoughts?
Any thoughts?
<form action='' method=post>
<input class='main_search' type='text' name='PrimSearch' autocomplete=off>
<div style='display:none;'><input type='submit' name='MainSearch_y' value='submit'></div>
<input type='image' border=0 src='http://www.fhaappraisershere.com/images/search.gif' name='MainSearch' onClick=\"this.submit();\">
</form>
you need to assign an action to the form. If you're posting to the same script that contains the form, you need to supply the name of the script.
ASKER
I am submitting to an included file. ie <? include ("submit"); ?>
This form is on every page.
Could explain a little more. I am a little slow...
This form is on every page.
Could explain a little more. I am a little slow...
// The contents of submit.
if (isset($_POST['MainSearch_y'])){
$PrimSearch=$_POST['PrimSearch'];
$PrimSearch=strtoupper($PrimSearch);
if (($PrimSearch=='ENTER A ST OR ZIP CODE')||($PrimSearch=='')){
$search_message="<img src='images/exclaim.gif'> <b>You Must Enter Search Criteria</b>";
$pass="NO";
unset($_SESSION['search']);
}
if ((!ereg('[^0-9]', $PrimSearch)) && ((strlen($PrimSearch) < 5))){
$search_message="<img src='images/exclaim.gif'> <b>A Zip Code Must Contain 5 Digits</b>";
$pass="NO";
unset($_SESSION['search']);
}
if ($pass!="NO"){
$_SESSION['search']=$PrimSearch;
header("location: ?page=listing/results");
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I wish I had more points to give!
Thank you!
Thank you!
Open in new window