473,394 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

help with onclick submit

In an unnamed form, unnamed because it only submits an email address, I'm
trying to have the submit button clear the "e-mail" text value in the
textbox.

On the submit button I have the following:

onClick="if(this.form['e-mail'].value=='e-mail')this.form['e-mail'].value=''"

But it does not seem to work. Any ideas or suggestions?

Thanks in advance!
Sep 28 '05 #1
16 4767

John wrote:
In an unnamed form, unnamed because it only submits an email address, I'm
trying to have the submit button clear the "e-mail" text value in the
textbox.

On the submit button I have the following:

onClick="if(this.form['e-mail'].value=='e-mail')this.form['e-mail'].value=''"

But it does not seem to work. Any ideas or suggestions?

Thanks in advance!


You are accessing the form elements incorrectly. Try the following
instead:

this.form.elements['e-mail'].value

Sep 28 '05 #2

"web.dev" <we********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...

You are accessing the form elements incorrectly. Try the following
instead:

this.form.elements['e-mail'].value


Thanks but it does not seem to work.

This here works:

<input type="text" name="email" value="e-mail"
onClick="if(this.value=='e-mail')this.value=''">

Then right below I have the line for my submit button as per your
suggestion:

<input type="submit" value="Go!"
onClick="if(this.form.elements['e-mail'].value=='e-mail')this.form.elements['e-mail'].value=''">

Unfortunately it's not working.

Any other ideas?

Thanks!
Sep 28 '05 #3

John wrote:
"web.dev" <we********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...

You are accessing the form elements incorrectly. Try the following
instead:

this.form.elements['e-mail'].value


Thanks but it does not seem to work.

This here works:

<input type="text" name="email" value="e-mail"
onClick="if(this.value=='e-mail')this.value=''">

Then right below I have the line for my submit button as per your
suggestion:

<input type="submit" value="Go!"
onClick="if(this.form.elements['e-mail'].value=='e-mail')this.form.elements['e-mail'].value=''">

Unfortunately it's not working.

Any other ideas?

Thanks!


Sorry for the confusion, when you first posted I had thought the name
of your input element was "e-mail". Try the same solution this time
replacing 'e-mail' with 'email':

this.form.elements['email'].value

Sep 28 '05 #4

"web.dev" <we********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...

Sorry for the confusion, when you first posted I had thought the name
of your input element was "e-mail". Try the same solution this time
replacing 'e-mail' with 'email':

this.form.elements['email'].value


Thanks but it's still not working...

Sep 28 '05 #5

John wrote:
"web.dev" <we********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...

Sorry for the confusion, when you first posted I had thought the name
of your input element was "e-mail". Try the same solution this time
replacing 'e-mail' with 'email':

this.form.elements['email'].value


Thanks but it's still not working...


The current action is still submitting the form. The onClick even
expects a boolean value to be returned. To see the expected result you
are looking for, do the following:

<input type="submit" value="Go!"
onClick="if(this.form.elements['email'].value=='email'){this.form.elements['email'].value='';}
return false;">

Sep 28 '05 #6

"web.dev" <we********@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...

The current action is still submitting the form. The onClick even
expects a boolean value to be returned. To see the expected result you
are looking for, do the following:

<input type="submit" value="Go!"
onClick="if(this.form.elements['email'].value=='email'){this.form.elements['email'].value='';}
return false;">


Thanks, it makes sense, but it's still not working. I tried changing the
value from email to e-mail as that's the value in the previous statement is
but still nothing.
Sep 28 '05 #7
John wrote:
In an unnamed form, unnamed because it only submits an email address, I'm
trying to have the submit button clear the "e-mail" text value in the
textbox.

On the submit button I have the following:

onClick="if(this.form['e-mail'].value=='e-mail')this.form['e-mail'].value=''"

But it does not seem to work. Any ideas or suggestions?

What do you expect to happen when you click the submit button? You want
to submit the email value, don't you?
Mick
Sep 28 '05 #8
Lee
web.dev said:


John wrote:
"web.dev" <we********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
>
> Sorry for the confusion, when you first posted I had thought the name
> of your input element was "e-mail". Try the same solution this time
> replacing 'e-mail' with 'email':
>
> this.form.elements['email'].value
>


Thanks but it's still not working...


The current action is still submitting the form. The onClick even
expects a boolean value to be returned. To see the expected result you
are looking for, do the following:

<input type="submit" value="Go!"
onClick="if(this.form.elements['email'].value=='email'){this.form.elements['email'].value='';}
return false;">


Better:

Never, ever, use the onclick handler of a submit button.
Use the onsubmit handler of the form tag, instead.

Sep 28 '05 #9

"Mick White" <mw***********@rochester.rr.com> wrote in message
news:hn*****************@twister.nyroc.rr.com...

What do you expect to happen when you click the submit button? You want
to submit the email value, don't you?
Mick


Yes, but not if the email value == the initial value "e-mail"

In other words, I don't want an email address called "e-mail" to be
submitted so, so when they try to hit submit, the words "e-mail" go away
from the textfield.
Sep 28 '05 #10

"Lee" <RE**************@cox.net> wrote in message
news:dh*********@drn.newsguy.com...

Better:

Never, ever, use the onclick handler of a submit button.
Use the onsubmit handler of the form tag, instead.


Only problem with that is that the user never sees the text "e-mail"
disappear if it has to be submitted. Rather, I'd want them to see the text
disappear when they click on the submit button.This way, if the form is
submitted, then a blank address gets emailed instead of "email" being
submitted as an email address.
Sep 28 '05 #11
ASM
John a écrit :
"web.dev" <we********@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...

<input type="submit" value="Go!"
onClick="if(this.form.elements['email'].value=='email'){this.form.elements['email'].value='';}
return false;">


Thanks, it makes sense, but it's still not working. I tried changing the
value from email to e-mail as that's the value in the previous statement is
but still nothing.


<form action="foo.htm"
onsubmit="if(this.email.value=='e-mail'){
this.email.value='';
return false;
}
else
return true;">
<input type=text name="email" value="e-mail">
<input type=submit value=GO>
</form>

--
Stephane Moriaux et son [moins] vieux Mac
Sep 28 '05 #12
Lee
John said:


"Lee" <RE**************@cox.net> wrote in message
news:dh*********@drn.newsguy.com...

Better:

Never, ever, use the onclick handler of a submit button.
Use the onsubmit handler of the form tag, instead.


Only problem with that is that the user never sees the text "e-mail"
disappear if it has to be submitted. Rather, I'd want them to see the text
disappear when they click on the submit button.This way, if the form is
submitted, then a blank address gets emailed instead of "email" being
submitted as an email address.


Well, if you're not actually submitting anything, don't freaking use
a submit button. Use a regular button.

Sep 28 '05 #13

"Lee" <RE**************@cox.net> wrote in message
news:dh********@drn.newsguy.com...
Well, if you're not actually submitting anything, don't freaking use
a submit button. Use a regular button.


It *is* submitting something, an email address. But if the email address is
"email" I want it blank.
Sep 29 '05 #14

"ASM" <st*********************@wanadoo.fr.invalid> wrote in message
news:43**********************@news.wanadoo.fr...

<form action="foo.htm"
onsubmit="if(this.email.value=='e-mail'){
this.email.value='';
return false;
}
else
return true;">
<input type=text name="email" value="e-mail">
<input type=submit value=GO>
</form>

Thanks! :-)
Sep 30 '05 #15
Lee
John said:


"Lee" <RE**************@cox.net> wrote in message
news:dh********@drn.newsguy.com...
Well, if you're not actually submitting anything, don't freaking use
a submit button. Use a regular button.


It *is* submitting something, an email address. But if the email address is
"email" I want it blank.


If you're submitting, and you want something to happen first, and/or
you want the submission to be cancelled under certain circumstances,
then use the onsubmit handler of the form. Do NOT use the onclick
handler of the submit button.

Sep 30 '05 #16
ASM wrote on 29 sep 2005 in comp.lang.javascript:
<form action="foo.htm"
onsubmit="if(this.email.value=='e-mail'){
this.email.value='';
return false;
}
else
no need for the else here!
return true;">
<input type=text name="email" value="e-mail">
<input type=submit value=GO>
</form>


even shorter is:

onsubmit="
if(this.email.value!='e-mail')
return true;
this.email.value='';
return false;"
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 30 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Margaret Werdermann | last post by:
Hi all: I'm having a nasty time with a particularly difficult piece of code and was hoping someone might be able to help me. I have a FormMail form that originally worked perfectly. Then, I...
3
by: Robert Dell | last post by:
I have a problem comparing strings in an order form i'm writing. I want to give a running total at the bottom of the page and it appears to be working except it doesn't compare correctly (it...
3
by: ilia | last post by:
Hi All, I am a newbie in terms of Javascript, I found some code on the net to swap rows in a table using innerHTML, this works fine in Firefox but IE is complaining, after some googling around I...
7
by: Papelotte | last post by:
Hi all, I'm new to this forum and I am hoping that there is someone here who can help me. I have an ASP page that has javascript that works perfectly in IE, but not in Firefox. Can anybody tell...
4
by: sameergn | last post by:
Hi, I have an image in my HTML form which has onclick() handler. There is also a submit button and a text box. Whenever text box has focus and user presses enter, the onclick() event of...
1
by: dreamlab | last post by:
Hello, Can one of you javascript wizards help out a newbie, please? I’ve got a formHandler that is supposed to check for a good email address and name in the form after clicking the submit...
5
by: settyv | last post by:
Hi, Below is the Javascript function that am trying to call from asp:Button control. <script language="javascript"> function ValidateDate(fromDate,toDate) { var fromDate=new Date();
9
by: poml | last post by:
Hello, first time posting on thescripts.com, and I'm in dire need of some help. All I want to do is disable the submit button (not the entire form) onClick, and am wondering if this is possible. ...
16
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) ...
3
by: milov | last post by:
Project to do simulation testing (me teacher). Page one writes in real time to page two...both displayed at sam time with frames. Code below. Problem...I want to keep score. Each choice needs a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.