tags:

views:

41

answers:

5

Hey everyone,

I have a page where you can enter data within a series of texboxes (generated from php), and 2 buttons, GetData and SaveData. I want to be able to press enter when editing the texboxes, and it would perform the same action as clicking the SaveData button (onclick="onSave();"). I can acheive this by doing the following:

<form id="editForm" name="editForm" action="onSave();">

but when I press enter, the page is redirected to the page, without the php post (ex.:www.mypage.com/index.php, instead of www.mypage.com/index.php?edit_data=true)

How do I achieve what I want?

Thanks,

Dave

+1  A: 

Make sure that your onSave(); returns false, and change action to onsubmit="return onSave();".

Oded
A: 

hmm... did you intentionally forgot the tag method="POST" ? :)

Puaka
+1  A: 

try <form id="editForm" name="editForm" action="onSave();return false;">

ULysses
thanks, this was part of the solution, second part was to replace to action attribute by the onsubmit attr.
David Menard
A: 
  1. button1 as Submit button

  2. button2 as type='button' on cliking button2 call javascript function which create lik using window.location.href="www.mypage.com/index.php?edit_data=true"

Salil
I simply put button1 outside of the form
David Menard
A: 

The answer was (thanks to Ulysses for part fo the answer):

<form id="editForm" name="editForm" onsubmit="onSave();return false;">

My onSave(); function did return false, but since it was doing the redirection, I had to put the return false after the onSave(); (explain why??)

Thanks!

David Menard