473,758 Members | 2,340 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="docume nt.PdcSurvey.Pd cButtonPressed. value='next';" />
--------------------------------------------------------------------

*Here is the 2nd onclick event:
--------------------------------------------------------------------
onClick='PdcSur vey.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="docume nt.PdcSurvey.Pd cButtonPressed. 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 14231
On 13 Feb 2004 06:23:37 -0800, EviL KerneL <fs****@yahoo.c om> 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="docume nt.PdcSurvey.Pd cButtonPressed. 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.f orm.PdcButtonPr essed.value='ne xt';
this.value='Ple ase 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.PdcSu rvey", 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.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
Michael Winter <M.******@bluey onder.co.invali d> wrote in message news:<op******* *******@news-text.blueyonder .co.uk>...
On 13 Feb 2004 06:23:37 -0800, EviL KerneL <fs****@yahoo.c om> 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="docume nt.PdcSurvey.Pd cButtonPressed. 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.f orm.PdcButtonPr essed.value='ne xt';
this.value='Ple ase 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.PdcSu rvey", 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.c om> 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="docume nt.PdcSurvey.Pd cButtonPressed. 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.******@blueyo nder.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
3664
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 events in the <img> tag). <input id="StdDev Value" name="StdDevButton" type="button" value="Standard Deviation Value" onclick="readStdDevValue()"/>
4
1746
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"> <html> <head> <title>Bow's and foggy's stored signatures</title> <script type="text/javascript">
6
9942
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 when you click on the image, it briefly shows the div, and then reloads the page to the window.location url. Is there a way of preventing the onClick of the row (<tr>) from doing
5
5848
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. Thanks kai
11
3033
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. It works perfectly (assigning the correct images and the correct onclick events to the correct <atags):
2
18563
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 adding to the rendered element's OnClick handler using GetPostBackEventReference. How can I provide a client-side onclick handler and then to use the aspnet form submit method such that I can also subscribe to the server-side events too?
4
14830
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
4075
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'" onMouseOut="this.style.background='#00ff00'" onClick="window.frames.eventsDisplay.location = 'MB2eventlistTimeline.php?movieID=<?php echo $movie->movieID;?>&events=<?php echo $timeline->eventCategory;?>'; parent.playClip(<?php echo $timeline->eventID?>, <?php echo...
0
9492
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10076
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9908
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9740
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7287
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2702
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.