Jump to content

[SOLVED] Image Sumit With Enter Button


phpretard

Recommended Posts

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'.

 

...and yes

if (isset(I_Know_y)){
blah

Link to comment
https://forums.phpfreaks.com/topic/129114-solved-image-sumit-with-enter-button/
Share on other sites

Thanks for the quick response.

 

// FORM PAGE

<form action='SUBMITPAGE' method=post>
<input type='text' name='PrimSearch' /> 
<type='image' src='/images/search.gif' name='MainSearch' /></td>
</form>


// SUBMIT PAGE

if (isset($_POST['MainSearch_y'])){

echo "Enter Button Won't Work";

}

Is this the actual code you are using?

 

1) for your button, you have <type='image' src='/images/search.gif' name='MainSearch' /> it should have input before type to look like this <input type='image' src='/images/search.gif' name='MainSearch' />

 

2)Submitpage, doesn't have an extension on it, such as php, html

 

I am sure you just threw that together for example, but def. make sure you are still using <input not just <type

 

I have tested w/ <input in front in Firefox, and works when you hit enter on the button

Andy-H: I don't get it?

 

Yes I am using <input...

 

There was a lot of useless info to post (my bad).  I should mention it works great when the image is "clicked".

 

It does work in firefox but...I wish everyone used firefox.

 

Any work around for IE?

I have been searching the internet for 2 hours and nothing refers to an image as the submit obj.

 

So should I $rephrase the question?

 


if ($rephrase=='Yes'){$question="How can I force the focus?";}

else {echo"beat it with this question!";}

I have been searching the internet for 2 hours and nothing refers to an image as the submit obj.

 

So should I $rephrase the question?

 

 

It's got absolutely nothing to do with the form of the 'submit' thing. I searched the internet for 2 seconds for "submit form on enter javascript".

 

http://www.google.ca/search?q=submit+form+on+enter+javascript&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a

It turns out the browser action changes if there is a single text field or if there are more than one. If you add a second text field to your test code, it will probably stop working in the browser that it seems to be working in now.

 

Here is a link I found (among the thousands that a search on how to do this common task will find) that shows how to force the enter key to submit a form - http://jennifermadden.com/javascript/stringEnterKeyDetector.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.