473,385 Members | 1,907 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,385 software developers and data experts.

Combining two OnClick Events

Hi -

I am working on a survey project which has a next button that takes
you to the next set of questions and so on. It does this by means of
an OnClick event which takes the answers from the questions and adds
them to a database while taking you to the next page. I have a second
onclick event I would like to combine with the above which changes the
value of the button to "please wait" (to prevent the user from click
on the buton more than once). When I try these events individualy they
work just fine, but for the life of me I cannot figure out how to
combine them.

*Here is the 1st click event:
--------------------------------------------------------------------
<input class="submit-button" type="submit" name="next" value="Next"

onclick="document.PdcSurvey.PdcButtonPressed.value ='next';" />
--------------------------------------------------------------------

*Here is the 2nd onclick event:
--------------------------------------------------------------------
onClick='PdcSurvey.next.value="Please Wait...";return true'>
--------------------------------------------------------------------

I have tried adding a semicolon to divide them both but that does not
seem to work. Here is what I did:

<input class="submit-button" type="submit" name="next" value="Next"

onclick="document.PdcSurvey.PdcButtonPressed.value ='next';" /;
'PdcSurvey.next.value="Please Wait...";return true'>

I have tried several ways to do this but I cannot seem to get them to
work together. Can anyone shed some light?

Thanks!
Jul 20 '05 #1
3 14215
On 13 Feb 2004 06:23:37 -0800, EviL KerneL <fs****@yahoo.com> wrote:

[snip]
I have tried adding a semicolon to divide them both but that does not
seem to work. Here is what I did:

<input class="submit-button" type="submit" name="next" value="Next"

onclick="document.PdcSurvey.PdcButtonPressed.value ='next';" /;
'PdcSurvey.next.value="Please Wait...";return true'>
1) The whole event string needs to be in a single set of double quotes.
You have split them.
2) The string must be on one line, just like any other HTML attribute
value. New lines can only appear between attribute/value pairs.
I have tried several ways to do this but I cannot seem to get them to
work together. Can anyone shed some light?


<input class="submit-button" type="submit" name="next" value="Next"
onclick="this.form.PdcButtonPressed.value='next';
this.value='Please wait...';">

The last line should not be wrapped, but line length limits forced me to
do it.

You should notice that I shortened the string slightly using the "this"
operator. In an intrinsic event, "this" refers to the current element; in
this case, the submit button "next". This allows you to change the value
of the button simply using "this.value='...'". Furthermore, all form
controls have the property, "form", which refers to the containing form
element. Instead of "document.PdcSurvey", you can use "this.form".
Finally, I removed the return statement: unless you are returning false,
it is not required.

Hope that helps,
Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
Michael Winter <M.******@blueyonder.co.invalid> wrote in message news:<op**************@news-text.blueyonder.co.uk>...
On 13 Feb 2004 06:23:37 -0800, EviL KerneL <fs****@yahoo.com> wrote:

[snip]
I have tried adding a semicolon to divide them both but that does not
seem to work. Here is what I did:

<input class="submit-button" type="submit" name="next" value="Next"

onclick="document.PdcSurvey.PdcButtonPressed.value ='next';" /;
'PdcSurvey.next.value="Please Wait...";return true'>


1) The whole event string needs to be in a single set of double quotes.
You have split them.
2) The string must be on one line, just like any other HTML attribute
value. New lines can only appear between attribute/value pairs.
I have tried several ways to do this but I cannot seem to get them to
work together. Can anyone shed some light?


<input class="submit-button" type="submit" name="next" value="Next"
onclick="this.form.PdcButtonPressed.value='next';
this.value='Please wait...';">

The last line should not be wrapped, but line length limits forced me to
do it.

You should notice that I shortened the string slightly using the "this"
operator. In an intrinsic event, "this" refers to the current element; in
this case, the submit button "next". This allows you to change the value
of the button simply using "this.value='...'". Furthermore, all form
controls have the property, "form", which refers to the containing form
element. Instead of "document.PdcSurvey", you can use "this.form".
Finally, I removed the return statement: unless you are returning false,
it is not required.

Hope that helps,
Mike

It sure did! A million thanks man. One question though, what did the
"/" do for the previous line? It seems to be working fine without it
so I am wondering.

In any case, thanks again for your help!
Jul 20 '05 #3
On 19 Feb 2004 05:39:23 -0800, EviL KerneL <fs****@yahoo.com> wrote:

[snip]
It sure did! A million thanks man.
You're welcome.
One question though, what did the "/" do for the previous line? It
seems to be working fine without it so I am wondering.


I assume you mean the slash at the end of the first line below?

onclick="document.PdcSurvey.PdcButtonPressed.value ='next';" /;
'PdcSurvey.next.value="Please Wait...";return true'>

It does nothing. The onclick attribute value ends at the second double
quote (next';"). The browser will then attempt to find another
attribute/value pair. The rest of the tag, from "/;" onwards, is invalid
HTML so the browser should just ignore it.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4

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

Similar topics

4
by: masantha wee | last post by:
Hi all, I am using Firefox and embedding Javascript in html. I understand that we can use mouse events by coding them in the body of html (by creating a button or anything and by adding in the...
4
by: David. E. Goble | last post by:
Hi All; I am trying to combine to picture galleries onto te one page. But its not quite working. Here is what I have so far. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">...
6
by: Cockroach | last post by:
Hello, I have a problem where the onClick of a table row will activates a window.location event, and inside a cell in that row, an image onClick event shows/hides a div. The problem is that...
5
by: kai | last post by:
Hi, In ASP.NET , what is the difference between OnClick and Click events for a button? Because we have button click event, it can trigger events, why we still need OnClick? Please help. ...
11
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
2
by: =?Utf-8?B?TWFyaw==?= | last post by:
I am writing a control and want to handle an OnClick event on the client-side before then conforming to the postback mechanism. I have got the server-side events working for my OnClick event by...
4
by: getsanjay.sharma | last post by:
Is there any way I can attach a function dynamically which takes some parameters ? <html> <head> <script> doSomething = function(x) { alert(x); }
11
by: nma | last post by:
Hi How can I make the anchor link once I do onclick? <td width="<?php echo ($cellwidth); ?>" height="17" bgcolor="#00ff00" onMouseOver="this.style.background ='red'" ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.