• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

HTML question

I want to create a form in HTML to submit data.
For example i have two text boxs and two buttons

<input type="text" name="textfield">
<input type="text" name="textfield2">
<input type="submit" name="Submit" value="Submit">
<input type="submit" name="Submit2" value="Submit">

when the browser load the page, how to set the cursor on the first text box?

after typing thing in the two text boxs, how to set the enter key to be the first button so that when press enter key, the result is as same as clicking the first button?
 
Originally posted by: StanleyFish

after typing thing in the two text boxs, how to set the enter key to be the first button so that when press enter key, the result is as same as clicking the first button?

it should happen automatically - though I don't think you should use 2 submit buttons :Q 😕
 
Originally posted by: joinT
Originally posted by: StanleyFish

after typing thing in the two text boxs, how to set the enter key to be the first button so that when press enter key, the result is as same as clicking the first button?

it should happen automatically - though I don't think you should use 2 submit buttons :Q 😕

No reason not to. They could be assigned different values to trigger different events through a script, but in order for that to work, they should be part of a button array, simply give them the same name.

Also, it should (at least in IE) just submit the form, not necessarily send the value of the first submit button. In order for this to work, you may want to add a onSubmit action to the form, and have it validate that they actually clicked one of the submit buttons, something like this:

<script language=JavaScript><!--
function VerifySubmit(){
     if(document.form1.submitbutton.value==""){
          alert("Please select an action.");
          return false;
     }else{
          return true;
     }
}
//-->
</script>

<form name=form1 onSubmit="return VerifySubmit();">
 
Back
Top