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 April 10th, 2004, 11:29 PM
Authorized User
 
Join Date: Apr 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to pigtail Send a message via Yahoo to pigtail
Default Change a button's name dynamically

I tried to change a button name dynamically but couldn't. Here is the code, can someone tell me why?

<body>
<script language="JavaScript" type="text/javascript">
<!--
var working = false;
function StartWork() {
if (!(working)) {
    working = true;
    button1.Value='STOP'; }
else {
    working = false;
    button1.Value='START';}
}
//-->
</script>
<input type=button name=button1 value="START" onclick='StartWork()'>



 
Old April 11th, 2004, 02:47 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Is this what you're going for?

Code:
<script language="JavaScript" type="text/javascript">

    function change_button(this_button)
    {
        document.getElementById(this_button).value = (document.getElementById(this_button).value == 'Hello')? 'World' : 'Hello';
    }

</script>

<form action="javascript:void(0);">
    <input type='submit' name'button' value='Hello' id='this_button' onclick='change_button("this_button");' />
</form>
hth,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old April 11th, 2004, 06:02 PM
Authorized User
 
Join Date: Apr 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to pigtail Send a message via Yahoo to pigtail
Default

Yes, thank you.






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to dynamically change an HTML page kpnikhil PHP How-To 1 September 7th, 2007 03:53 AM
How to change the globalization dynamically? sfs00784 General .NET 1 July 16th, 2004 04:13 AM
How to change report's objects dynamically. Vadim Crystal Reports 2 May 17th, 2004 09:40 AM
dynamically change the row colors in datagrid bvrao VS.NET 2002/2003 0 December 24th, 2003 06:19 AM
Dynamically change event handlers oranginalab Javascript How-To 2 July 31st, 2003 10:11 AM





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