[OT] Question on javascript
Stephen Woodbridge
woodbri at SWOODBRIDGE.COM
Wed Jun 1 09:33:57 PDT 2005
Wim,
Thanks you, I never thought of doing it that way. It turns out that
there is a simple fix to the problem for me and that is to:
CHANGE:
<form onsubmit="nosubmit();">
TO:
<form onsubmit="return nosubmit();">
This is one of the reasons I hate javascript, but that is a whole other
story. I have the highest regard for people that work in javascript!
Thanks everyone for the help, I love this list!
-Steve
Wim Blanken wrote:
> Hello Stephen,
>
> Correct me if I am wrong I think you want to make sure that an enter
> does not submit a form.
> I use the following code for this and it works in ie and mozilla.
>
> -----------------------------------------------------------------------------
>
> <script language="javascript"> function handleEnter (field, event) {
> var keyCode = event.keyCode ? event.keyCode : event.which ?
> event.which : event.charCode;
> if (keyCode == 13) {
> var i;
> for (i = 0; i < field.form.elements.length; i++)
> if (field == field.form.elements[i])
> break;
> i = (i + 1) % field.form.elements.length;
> field.form.elements[i].focus();
> return false;
> }
> else
> return true;
> }
>
> </script>------------------------------------------Then I use the
> following form-code in my html to use the function above.... <input
> size=15 type=text onkeypress="return handleEnter(this, event)"
> name=name> Regards,Wim Blanken
>
>
> ----- Original Message ----- From: "Jeff Portwine" <jdport at VERITIME.COM>
> To: <MAPSERVER-USERS at LISTS.UMN.EDU>
> Sent: Wednesday, June 01, 2005 4:28 PM
> Subject: Re: [UMN_MAPSERVER-USERS] [OT] Question on javascript
>
>
>> let me do a little digging... I had this same issue once where I
>> didn't want
>> the user to submit the form by hitting enter, and to only be able to
>> submit
>> by pressing the submit button. I found some code that allowed me to
>> disable submitting from hitting enter in IE, but it wouldn't work for
>> Mozilla... and it seems that i got around the problem some other way in
>> mozilla but i can't remember just what i did or what the situation was.
>> I'll see if I can find it, and if it applies to your situation :)
>>
>> -Jeff
>>
>> ----- Original Message -----
>> From: "Stephen Woodbridge" <woodbri at SWOODBRIDGE.COM>
>> To: <MAPSERVER-USERS at LISTS.UMN.EDU>
>> Sent: Saturday, May 28, 2005 2:15 PM
>> Subject: [UMN_MAPSERVER-USERS] [OT] Question on javascript
>>
>>
>>> Hi,
>>>
>>> This is a little of topic, but it is related to building a web interface
>>> for mapserver.
>>>
>>> I have form in html that I do NOT want to submit.
>>>
>>> http://swoodbridge.com/~woodbri/t.html
>>>
>>> enter text in location and hit [enter], the form starts a submit and
>>> calls nosubmit() which puts up an alert and then return false; which
>>> should cancel the submit. But it does the submit anyway :(
>>>
>>> This is really annoying because I figure I'm doing something stupid, but
>>> I just don't see it.
>>>
>>> Any help would be appreciated.
>>> -Steve W.
>>>
>>> the html is:
>>>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>> "http://www.w3.org/TR/html4/loose.dtd">
>>> <html>
>>> <head>
>>> <title>Submit Test</title>
>>>
>>> <script type="text/javascript">
>>>
>>> function nosubmit()
>>> {
>>> alert('nosubmit');
>>> return false;
>>> }
>>>
>>> </script>
>>>
>>> </head>
>>> <body>
>>> <form onsubmit="nosubmit();">
>>> Location: <input type="text" name="address" size="40">
>>> <input type="button" value="Go" onclick="alert('hello')">
>>> </form>
>>> </body>
>>>
>>> </html>
>>>
>>
>>
>
More information about the MapServer-users
mailing list