Welcome to WebmasterWorld Guest from 54.146.55.156

Forum Moderators: open

Message Too Old, No Replies

give regular button same interface as a submit button

     
5:39 am on Feb 20, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:June 30, 2005
posts:93
votes: 0


hey I created a form that submits data with ajax the problem is that I want the user to be able to send this data when they hit enter not just when they click on the button how can I get this effect.
5:49 am on Feb 20, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


What is the code for the button?
<input type="button">?

Can it be changed to a submit button?

5:54 am on Feb 20, 2006 (gmt 0)

Full Member

10+ Year Member

joined:June 15, 2003
posts:302
votes: 0


Hi,
I had a similar problem where a form had a js "onClick" submit button and I needed pressing enter submit as well. The only work around that worked was that I put a submit input in the form that I hid by using div at absolute negative pixels. I don't know anything about Ajax, but it might work. Keep in mind that negative div might trigger a hidden text red flag with SEs. The page I did this on still has PR and is cached By SEs.
7:07 am on Feb 20, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


I would recommend replacing the <input type="button"> with <input type="submit"> and then use the form's
onsubmit
attribute to trigger whatever JavaScript you want to run. Just remember to return false to prevent the form from submitting.
2:32 pm on Feb 20, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:June 30, 2005
posts:93
votes: 0


Thanks that just returning false was the type of thing I was looking for. Now it acts like a submit button without actually submitting the form.