473,405 Members | 2,154 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,405 software developers and data experts.

Problems with javascript buttons not showing up?

103 100+
I am working on a script where through a loop buttons are formed with different onClick parameters, but when my html document opens and calls the function, nothing happens. Can some look at the code and tell me what I am obviously doing wrong. Note: I am a beginner and experitmenting to learn.

My Code:
Expand|Select|Wrap|Line Numbers
  1. buttonNames = new Array("Next","Previous","Home");
  2. function displayButtons{
  3. for (i=0; i < buttonNames.length; i++)
  4. <input type="button" value= buttonNames[i]
  5. for (i in buttonNames)
  6.     {     
  7.         window.location = new array("next.html","previous.html","home.html");
  8.         onClick="window.location[i]";
  9.     }>
Jan 5 '11 #1
1 1755
Dormilich
8,658 Expert Mod 8TB
you’re doing pretty much everything wrong.

- your function definition misses the parameter part (that between the function name and the opening {)
- bare HTML tags (or parts thereof) are invalid javaScript code
- events in JavaScript are defined through Event properties/handlers
- you use a standard for() loop to loop through an array
- if you define a HTML attribute without quotation marks, the value goes only up to the next whitespace character

you should definitely read a JavaSript & HTML tutorial, for instance at www.w3schools.com.
Jan 5 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Trvl Orm | last post by:
I am working with 2 frames, Left and Right and the main code is in the left frame, which has been attached. Can someone please help me with this code. I am new to JavaScript and can't figure it...
8
by: lancevictor | last post by:
I'm learning javascript, and toward that end, I am recreating a page "my way". The original page: http://stenbergcollege.com and the one that I'm creating:...
4
by: | last post by:
I wanted better control over the display of the command buttons, so I created Template columns for each command. (Otherwise the GridView was putting extras spacing around the images and such.) ...
0
by: sanmateof | last post by:
My radio buttons are showing the value besides the button even though no text is displayed. Below is my code: <td style="width: 100px"><asp:RadioButtonList ID="RadioButtonList16" runat="server"...
3
by: Delfry | last post by:
Hello! That's the my (I guess quite lame) question: I use a Speedbuttons formed in a group and I cant figure out how to make them change their appearance once they are pressed. I mean there are...
0
by: jase_rw | last post by:
HI there, I've developed a form and the toolbar control is causing problems. When I add some buttons, the toolbar appears not to refresh itself properly and has a white background. Then the...
3
by: rudeman76 | last post by:
Hi, I have a form that has no menu bar (so people cannot go playing) and when the admin presses the admin button they have to enter in a password. After they enter in the password the menubar...
1
by: xxpinkyxx | last post by:
I have created a form asking some basic questions eg Name Address Length Type after the user has enetred there details they need to click on a button, this button needs to access the details...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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
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,...

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.