Click to See Complete Forum and Search --> : choose submit-button


Kr|Z
07-20-2003, 04:50 PM
I have a form with to submit-buttons.
When you click in any of the text-fields in the form, the first of the submit-buttons gets the focus. So if you submit the fields by just pressing enter, the form will submit with the first button.

Is there any way to change that "default" button in a form, so I can get the second button to get the focus instead?

Exuro
07-20-2003, 05:46 PM
I think that just changing the first submit from type Submit to type Button would work for that... But I'm not sure exactly what you're trying to do here so I can't be sure... If that doesn't help then I'd post a link or your code or something so that we can see what you're trying to do.

Kr|Z
07-21-2003, 04:27 AM
That worked for the focus part... But it wont submit the form when its type button.

The reason why I want this is that Im working on a webmail script. When you send a mail you'll use the second submit-button. The first button is for uploading a file-attachment. And when you upload a file using the first button, it still have to submit the text-fields so the user dont loose all the values (thats why it have to be in the same form).

Here is an example of my form:

http://home.no/krizonline/form.html

Exuro
07-21-2003, 11:40 AM
I still don't see what you're trying or why you're trying to do that on that form, but try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test</title>
</head>
<body>


<form method="post" action="form.html">

<input type="text" name="textfield"><br><br>

If you click inside the text field over here, you will see that Submit1 gets focused, and<br>
if you press enter the form submits with Submit 1. I want that changed to submit 2 without<br>
having to change their order.<br><br>

<input type="button" name="submit1" value="Submit 1" onclick="document.forms[0].submit()"><br><br>

<input type="submit" name="submit2" value="Submit 2">

</form>


</body>
</html>

Kr|Z
07-21-2003, 12:17 PM
Thanks, that worked fine =)