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

}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.