[thelist] dHTML Form Elements && tip re: Disabling the <enter> key to submit a form.

Tab Alleman talleman at autobex.com
Fri Dec 1 09:46:23 CST 2000


DOH!

Thanks James, for making me verify what I should have verified in the first
place.  I found the problem (too embarrassing to post).

as for a tip, um, well..somebody asked a while back about making a form NOT
submit when the <enter> key is pressed..I have a form that doesn't submit
when you press enter, and I think this is why (though it *could* be for some
other reason):

<tip>
To keep your user from inadvertantly submitting your form by pressing
<enter>, try getting rid of the <input type="submit">
also take the Action="" and Method="" out of your <form> tag (but DO give it
a Name="").  Instead try something like this:

(this part goes in your <script> area)

	function FormHandler(HowToAct,frm)
		{
		if (HowToAct == 'Script1')
			{
			document.forms[frm].method = "post";
			document.forms[frm].action = "Script1.asp";
			document.forms[frm].submit();
			}
		else if (HowToAct == 'Script2')
			{
			document.forms[frm].method = "post";
			document.forms[frm].action = "Script2.asp";
			document.forms[frm].submit();
			}
		}

(and in your <body> replace your submit button with this(these):  )

		<input type="button" value="Submit to Script1"
onclick="FormHandler('Script1','FormName')">
		<input type="button" value="Submit to Script2"
onclick="FormHandler('Script2','FormName')">


As you can see this has the added benefit of letting you submit the same
form info to different scripts depending on which button the user clicks.
You can hard-code the form name into your function (rather than passing it)
if you only have one form on your page that's going to use the function.

</tip>


-----Original Message-----
Tab,

> when I submit the form, the second select isn't in the Request.Form
> collection.  Can I not do this?

	Without seeing code, it's hard to say what might be the problem.
This should work, however. Make sure that you are assigning a unique name
attribute to your dynamically created select, and make sure that you are
creating it within the form element. If this doesn't help, pls either post a
url or relevant code. Thanks.






More information about the thelist mailing list