Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 15th, 2003, 09:32 AM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default onclick event not working?

here's a strange one...i've got this submit button, that has always worked just fine, on a form:

<input type="submit" value="Submit" onclick="myform.email_to.value += ', [email protected]'">

the idea is that on the form the user enters his e-mail address in the email_to text box, then i append my own, and this becomes the destination list for the form handler, which e-mails the contents of the form (including the email_to field) to both of us. never had any trouble with it until a couple of days ago. what happened was that the user got e-mailed a copy of the form, but i didn't. looking at the value of the email_to field, sure enough it had the user's address but not mine.

how can this be? i can't see any way that could happen unless there is some sneaky way a form can be submitted without the onclick event firing on the submit button. i wondered at first if just pressing enter, rather than clicking the button, would skip that event, but it doesn't. any ideas?
 
Old September 15th, 2003, 09:55 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

How many browsers have you tested with the enter button theory? I'm sure there are some that behave differently. You might want to move this code into the "onSubmit" event handler of the form tag. This should ensure that it gets run even when someone presses enter. The only problem with this is that if you ever submit this form with a bit of JS (myForm.submit()) that onsubmit event doesn't fire. It's very strange but there are ways to work around it.

Peter
 
Old September 15th, 2003, 10:09 AM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

think i tested it on ie5.5 and netscape 7.1, though i can't really remember about netscape. i'm waiting to hear from the user who had the problem to find out what browser he used and how he submitted. thanks for the suggestion re: onSubmit; i'll give it a go.





Similar Threads
Thread Thread Starter Forum Replies Last Post
onClick event not working !!! muklee Javascript How-To 14 June 4th, 2008 04:08 PM
Generate onclick event collie Javascript 4 May 27th, 2008 09:22 AM
onclick event bjackman Access 6 July 15th, 2004 06:54 AM
onclick event pigtail Javascript 1 April 11th, 2004 03:10 PM
onClick Event mateenmohd Javascript 4 December 16th, 2003 01:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.