473,500 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's wrong with this script?

I need a button to change text everytime a person clicks it. It should
switch back and forth from "Request" to "Nevermind." For some reason, this
won't work at all. Does anyone see why it doesn't work?
function changeButton(buttonId)
{
if (document.getElementById)
{
var button=document.getElementById(buttonId);
if (button)
{
if (button.childNodes[0])
{
if (button.childNodes[0].nodeValue=="Request")
{
button.childNodes[0].nodeValue="Nevermind";
}
else
{
button.childNodes[0].nodeValue="Request";
}
}
else if (button.value)
{
if (button.value=="Request")
{
button.value="Nevermind";
}
else
}
button.value="Request";
}
}
else //if (button.innerHTML)
{
button.innerHTML="Nevermind2";
}
}
}
}
Jul 23 '05 #1
2 986
I guess this would be it:
else
}


I spent 30 minutes trying to figure out why this script wouldn't work.
GAH!
Jul 23 '05 #2
> I need a button to change text everytime a person clicks it. It should
switch back and forth from "Request" to "Nevermind." For some reason, this
won't work at all. Does anyone see why it doesn't work?
function changeButton(buttonId)
{
if (document.getElementById)
{
var button=document.getElementById(buttonId);
if (button)
{
if (button.childNodes[0])
{
if (button.childNodes[0].nodeValue=="Request")
{
button.childNodes[0].nodeValue="Nevermind";
}
else
{
button.childNodes[0].nodeValue="Request";
}
}
else if (button.value)
{
if (button.value=="Request")
{
button.value="Nevermind";
}
else
}
button.value="Request";
}
}
else //if (button.innerHTML)
{
button.innerHTML="Nevermind2";
}
}
}
}


(26) : error at character 9: Expected '{' and instead saw '}'.

JSLINT can be very helpful in spotting errors like this.

http://www.crockford.com/javascript/lint.html
Jul 23 '05 #3

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

Similar topics

10
3378
by: Greener | last post by:
Hi, I need help badly. Can you do client-side programming instead of server-side to capture the Browser type info? If this is the case, what's wrong with the following? <script...
5
1826
by: tin | last post by:
<script language="Javascript"> <!-- function apri (theURL,winName,features){ window.open (theURL,winName,features); var a=null; oldwindow = window.self; oldwindow.opener = window.self;...
6
2010
by: Rtritell | last post by:
Please can you find out what's wrong, fix the script and tell me what was wrong. Im just beginning <html> <head> <title>Random Mad Lib!</title> <script language="JavaScript"> <!-- Hide
17
2611
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
4
1603
by: Paul | last post by:
HI! I have a script that does not seem to work. can someone tell me what I am doing wrong here? <script language="JavaScript"> function firefoxautofix(){ parent.window.resizeBy(-1,-1)...
2
464
by: Miguel Dias Moura | last post by:
Hello, i want to open a new window when a button is clicked. I am working in ASP.net / VB. However my code is not working. This is my Script Code: <script runat="server"> Private Sub...
8
3117
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that...
6
1458
by: plemon | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
3
2131
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when...
2
2559
by: Tarik Monem | last post by:
OK! I've gone through a few tutorials and I cannot understand what I'm doing wrong casting_registration.php <table> <tr> <td> <form enctype="multipart/form-data" action="thankyou.php"...
0
7136
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
7018
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
7182
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
7232
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...
0
7397
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...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
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...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.