Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 15th, 2003, 09:32 AM
Registered User
Join Date: Sep 2003
Location: , , .
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 += ', myaddress@dummy.com'">

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?
Reply With Quote
  #2 (permalink)  
Old September 15th, 2003, 09:55 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

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.

Reply With Quote
  #3 (permalink)  
Old September 15th, 2003, 10:09 AM
Registered User
Join Date: Sep 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

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.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 06:02 PM.

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