JavaScript - Use Of Multiple Buttons
Hey guys,
I'm a noob with javascript and I only know simple HTML coding, so I have become stuck. I can program in other languages though, so I understand the principles. That being said, I have become stuck with something. My aim is to have a series of page where text is displayed, and then two or more buttons. Once a button is clicked, I want the screen to clear and it displays the next lot of text, followed by some more buttons. Once they are pushed, it continues on. So basically, each section has its own code that it pushes, plus its own buttons which lead to other sections. I am not trying to make a choose your own adventure book, but the layout is basically one of these. I can do this in another language by simply having a few sections. Inside each section, it retrieves the option and proceeds. However, when I am trying to do this, I am getting confused. The way my other programming experience tells me to write it, I would write a function which is called for each section, and it would display the text, the buttons, and return to the main function in the program. However, because the buttons are in HTML, I cannot put code for the new buttons instead the functions. If I put the code inside the body of HTML, it will automatically be displayed. I cannot write an if statement to determine which buttons are displayed. Can you please give me some advice around this? I hope I have made myself clear enough to be understood!! One other thing I should mention, I really want to be able to do this in a single HTML file instead of calling other files. I think this would work fine by using frames and multiple HTML files, but I would prefer not to unless I really need to. One file would be much better for me. Thanks! Below is the basic code I am working from. It displays the first section with some text, displays two buttons and it goes to the next section on a button click. Code: <html> <head> <script type="text/javascript"> function button1() { document.write("Button 1 was pushed. Insert text here. Choose from two new buttons below:"); } function button2() { document.write("Button 2 was pushed. Insert text here. Choose from two new buttons below:"); } </script> </head> <body> <form> <input type="button" value="Button1" onClick="button1()" /> <input type="button" value="Button2" onClick="button2()" /> </form> </body> </html> Similar TutorialsSo I used to do a bit of programming about 100 years ago, and now I know just enough to get myself hurt while trying to do it. I was asked to do a couple of javascript quizzes for a project, and was able to produce them through a combination of sheer luck and a coursebook I still have from ~2001. I'm now working on a new one and have run into a wall, even though I know it should be a simple process. I'm basically looking to make 12 sets of 4 radio buttons, each with a value of 1-4. At the bottom of the page there are 4 text boxes that I would like to keep a running total of all of the 1's, 2's, 3's and 4's as they are selected. I'm not having any luck. Anyone willing to take a stab? Code: <HTML> <HEAD> <TITLE>Communication Styles</TITLE> <SCRIPT type="text/javascript"> </SCRIPT> </HEAD> <BODY> <BR><BR> <CENTER><H1><U>Communication Styles</U></H1></CENTER> <BR><BR> <FORM> <TABLE> <TR><TD> <TR><TD><B><U>1. Do you tire more easily? Feel fatigued rather than energetic?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec11" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec11" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec11" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec11" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>2. Are you annoyed by people telling you that you don't look so good lately?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec12" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec12" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec12" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec12" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>3. Are you working harder and harder and accomplishing less and less?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec13" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec13" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec13" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec13" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>4. Are you increasingly cynical and disenchanted?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec14" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec14" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec14" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec14" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>5. Are you often invaded by a sadness you can't explain?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec15" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec15" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec15" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec15" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>6. Are you forgetting (appointments, deadlines, personal possessions)?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec16" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec16" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec16" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec16" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>7. Are you increasingly irritable? More short-tempered? More disappointed in the people around you?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec17" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec17" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec17" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec17" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>8. Are you seeing close friends and family members less frequently?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec18" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec18" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec18" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec18" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>9. Are you too busy to do even routine things like make phone calls, read reports or send out holiday cards?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec19" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec19" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec19" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec19" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>10. Are you suffering from physical complaints (aches, pains, headaches)?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec110" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec110" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec110" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec110" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>11. Do you feel disoriented when the activity of the day comes to a halt?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec111" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec111" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec111" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec111" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B><U>12. Is joy elusive?</U></B><BR><BR> <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec112" value="1" type="radio"> 1 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec112" value="2" type="radio"> 2 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec112" value="3" type="radio"> 3 <TR bgcolor="#FFFFFF" onMouseOver="this.bgColor='#B7EDFF';" onMouseOut="this.bgColor='#FFFFFF';"><TD><input name="sec112" value="4" type="radio"> 4 <TR><TD><BR> <TR><TD><B>1's: </B><input type="text" name="SecTotal1" id="sectotal1" value="" maxlength="15" size="15" class="textbox"><BR> <TR><TD><B>2's: </B><input type="text" name="SecTotal2" id="sectotal2" value="" maxlength="15" size="15" class="textbox"><BR> <TR><TD><B>3's: </B><input type="text" name="SecTotal3" id="sectotal3" value="" maxlength="15" size="15" class="textbox"><BR> <TR><TD><B>4's: </B><input type="text" name="SecTotal4" id="sectotal4" value="" maxlength="15" size="15" class="textbox"><BR> </TABLE> <BR><BR><BR> <input type="button" name="reset_form" value="Reset Form" onclick="this.form.reset();"> <BR><BR><BR><BR> </FORM> </BODY> </HTML> I know it should be simple, but I guess it's been too long. Thanks in advance for any help people are willing to give fyi, I have limited experience with web programming (even less with javascript). I am trying to search a database of molecules and display several columns for each returned molecule in a table in a new page (view_all.cgi). Within this table I have a button for each molecule from the database which I would like to be able to click it and view all of it's information in a new page (view_one.cgi) However, I also have a column in my table in view_all.cgi filled with check boxes so that only some of the returned molecules can be checked and then downloaded using a script (get_checked.cgi). QUESTION: How can I handle the table data so that one button sends one row of the table to view_one.cgi, while another button sends multiple columns of the table to get_checked.cgi without using nested forms? Thanks, Tom EDIT: A better question. I have the first part of my question working (sending one row of a table to view_one.cgi). So, using javascript, how can I get the status (checked/unchecked) of all the check boxes on a page and send the information to get_checked.cgi? Hate to ask this as I know it's an easy one but surprisingly Google turns up no clear/simple answers! I'm modifying some old code and am not JS programmer (I'm a PHP programmer) and this is driving me nuts. The existing code makes sure that when the form is submitted that there isn't a missing value. There's also some hidden input values. The JS starts out function checkform(orderform) and the form tag includes onsubmit="return checkform(this);"> I can add an alert to the form to see varius input values, such as a hidden value for the input name 'description' I can use: alert (orderform.description.value) Eazy peazy. However the form has two different input type=image buttons now and I need to do some branching in the JS depending on which image button they press. I recall IE had an issue where it only sends the x and y coordinates So I figure an easy to determine which image button was pressed is just check to see if the x or y value for each button is non-zero. But I can't for the life of me figure out how to access the value. Example: alert (orderform.button1.x.value) doesn't work. Can someone refresh my memory or suggest an entirely different method for detecting which image button was used to submit a form? THanks in advance! Hi, I hope someone can help me. I'll be honest and say I don't know much about javascript, but am fairly comfortable in html. I am building a website that will have multiple image swaps on multiple pages. I am building this in wordpress, and I'm guessing that means my approach will be different than if I wasn't using wordpress. Here's how one page would work: There are 10 images shown. 1,2,3,4,5,6,7,8,9,10. When number 1 is clicked on, I want a new image - 1a. When 2 is clicked on, 2a. So there are 20 different images in all on a given page. Also, I want the user to be able to click on the image again to restore the original image. I would prefer onclick to onmouseover. There will be literally dozens of pages like this on the site, managed by wordpress, so hundreds of images to swap. Basically the first image is a question - the second image is the answer. Is this possible? Hi all, I'm having trouble getting the following right: Code: <IMG border="0" onMouseOver=this.src="home2.gif" onMouseOut=this.src="home.gif" onClick=this.src="home2.gif" SRC="home.gif"> The idea is that after somebody clicks it, the button will remain home2.gif, but ofcourse if u mouseout after the click it will return to home.gif. Can somebody please help me with this problem?! I'm not really good at js, so I've been struggling with this for quite a few days ! Thnx alot! Sjaroow hello, I created this program to hold 5 cd's and some information relating to them. I keep getting an error that says: cannot find symbol symbol : class ButtonListener location: class inventoryprogram.InventoryProgram ActionListener btnListen = new ButtonListener(); // create listener here is the part of code with the actionlistener in it [CODE] private JPanel createButtonPanel() { // begin method createButtonpanel method ActionListener btnListen = new ButtonListener(); // create listener // create button objects JButton nextButton = new JButton("Display Cd"); // create and label button nextButton.setActionCommand("Next"); // action command for click nextButton.addActionListener(btnListen); nextButton.addActionListener(this); JPanel panel = new JPanel(); panel.add(nextButton); // add next button to panel return panel; // return panel } // end method createButtonPanel [ICODE] To be clear my approach to coding is basically that of building some kind of Java Frakenstein's Monster... which also explains why everything I create invariably ends up in a windmill on fire... This is what I have managed to put together so far: Code: <script type="text/javascript"> var homeDown = new Array() homeDown[0] = "images/home001.png"; homeDown[1] = "images/home002.png"; homeDown[2] = "images/home003.png"; homeDown[3] = "images/home004.png"; homeDown[4] = "images/home005.png"; homeDown[5] = "images/home006.png"; homeDown[6] = "images/home007.png"; homeDown[7] = "images/home008.png"; homeDown[8] = "images/home009.png"; homeDown[9] = "images/home010.png"; homeDown[10] = "images/home011.png"; homeDown[11] = "images/home012.png"; homeDown[12] = "images/home013.png"; homeDown[13] = "images/home014.png"; homeDown[14] = "images/home015.png"; var homeOver = new Array() homeOver[0] = "images/image001.png"; homeOver[1] = "images/image002.png"; homeOver[2] = "images/image003.png"; homeOver[3] = "images/image004.png"; var x=0; function NormalImage() { document.getElementById("button1").src="images/home.png"; } function MouseOver() { document.getElementById("button1").src=homeOver[x]; x++; setTimeout("MouseOver()", 8); } function MouseDown() { document.getElementById("button1").src=homeDown[x]; x++; setTimeout("MouseDown()", 8); } </script> ...and the HTML: Code: <a href="http://www.google.com"> <img id="button1" src="images/home.png" onmousedown="MouseDown(button1)" onmouseover="MouseOver(button1)" onmouseout="NormalImage(button1)"/> </a> I'm sure that's probably the wrong way of doing it but it vaguely works. What I ultimately want is a button that will play the long image sequence on click and the shorter sequence on mouse over. However at the moment it appears that the states of the mouse being over and clicked are clashing so I need something to ignore mouseover images on click and another bit to reset the count on mouseover so it can play again. If I remove the mouseover event the animation on mousedown plays well, though I suspect it might be necessary to preload the images when it's online. Alternatively if anyone feels like writing a much easier bit of script that will do the same thing and slap me for being stupid that is acceptable too... hello, Im trying to write a program when the user clicks on the button, the textbox should display "how are you ". This is what I tried : <html> <head> <title>"Click"</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p> <input name="text1" type="text" id="text1" value="textbox 1" onFocus="this.style.background ='yellow'" onBlur="this.style.background='white'"> </p> <p> <input name="text2" type="text" id="text2" value="textbox 2" onFocus="this.style.background = 'yellow'" onBlur="this.style.background='white'"> </p> <p> <button onclick="textbox1.value="how are you">Click Me!</button> </p> </body> </html> There has to be a way to do what I want to do but I'm fugged iif I know how. Here's the problem... A page has three frames - top, left and disp. Top and left contain a number of buttons that display another page in disp. All the buttons need to behave as one set of radio buttons; when a button is clicked any other button returns to the non-clicked state. The really awkward bit is there's an image in top that changes depending on the currently clicked button and that image is behind the buttons. Here it is in pseudocode of sorts. Code: On click button[n] Button[LastClicked].Image := Button[LastClicked].UnClickedImage; Button[n].Image := Button[n].ClickedImage; Top.Image := Button[n].TopImage; end; I hope that makes sense. If some kind soul has any idea of how to do that I'd be very grateful. Thanks. Simon. I'm having trouble with a 3-state rollover with rollClick staying active for a series of buttons. Each button reveals it's own content within the same page. Here's a working example of what I have. The roll in and out works fine at first, but after the second click the images start getting jumbled together. Something to do with the lastClick code at the bottom I think. HTML-side my button images get class="rollover" and a unique id. Code: window.onload = rolloverInit; document.getElementsByClassName = function(cl) { var retnode = []; var myclass = new RegExp('\\b'+cl+'\\b'); var elem = this.getElementsByTagName('*'); for (var i = 0; i < elem.length; i++) { var classes = elem[i].className; if (myclass.test(classes)) retnode.push(elem[i]); } return retnode; }; function rolloverInit(){ var rollOvers = document.getElementsByClassName("rollover"); for(var i=0; i<rollOvers.length; i++){ setupRollover(rollOvers[i]); } } function setupRollover(thisImage){ //UP thisImage.outImage = new Image(); thisImage.outImage.src = "images/" + thisImage.id + "1.gif"; thisImage.onerror = thisImage; thisImage.onmouseout = rollOut; //OVER thisImage.clickImage = new Image(); thisImage.clickImage.src = "images/" + thisImage.id + "2.gif"; thisImage.onerror = rollOut; thisImage.onmousedown = rollClick; //DOWN thisImage.overImage = new Image(); thisImage.overImage.src = "images/" + thisImage.id+"2.gif"; thisImage.onerror = rollOut; thisImage.onmouseover = rollOver; thisImage.onmouseup = rollOver; } function rollOver() { this.src = this.overImage.src; } function rollOut() { this.src = this.outImage.src; } function rollClick() { if(lastClick){ lastClick.onmouseout = rollOut; lastClick.src = this.outImage.src; } this.src = this.clickImage.src; this.onmouseout = rollClick; lastClick = this; } var lastClick = null; What I'd also like, since these buttons act as tabs, is for the first button to already be in the rollClick active state on page load (since that button's content is already displayed by default). Is this possible? Thanks for any help you can provide! Hello there, Can some one gimme source code for greying out a button on php page. In my application i have one play button and one stop button in the html form. If i click play button it will update database with play and invoke a script. similarly with stop. so while they are being played i want this play button to be greyed out. or is there any way that i can only show stop button while playing and play button while not playing the files. HELP PLZZZZZZZZ i have a simple frame that looks like this http://i307.photobucket.com/albums/n...aker/help2.jpg i have 3 pages (side.html, page1.html and page2.html) the above picture has side.html and page1.html loaded on default, what i want to do is whenever i click on the page 1 button, page1.html will load on the right side and when i click on page 2 button, page2.html will load i cant figure out what the code for this is and googling for the solution isn't getting me anywhere help please Hi, I have buttons like these: PHP Code: <button type="button" onclick="izdas()">Iždas</button> <button type="button" onclick="miestas()">Miestas</button> <button type="button" onclick="map()">Žemėlapis</button> <button type="button" onclick="infantry()">Kariuomenė</button> <button type="button" onclick="biuld()">Statiniai</button> How I can add images on them?? Size would be 100x20px. Also, I would e thankful if someone would help me position them in one vertical line. Thanks in advance... I have the following buttons ... Code: <input id="newTaskButton" type="button" name="Good Morning" value="201" /> <input id="newTaskButton" type="button" name="Hello World" value="201" /> ... and the following javascript ... Code: <script type="text/javascript"> $(document).ready(function() { $("#newTaskButton").click(function() { alert(" " + document.getElementById("newTaskButton").name); }); }); </script> ... but I am having some trouble having the second button to response. My objective is to have 2 or more button that have the same click function (in this case, newTaskButton) but when clicked, it will produce different response. (in this case, the first button will response 'Good Morning' while the second button will response 'Hello World') Appreciate any help. Alternatives are welcome too. I'm Confused. My HTML: <form action="mail.php" class="contactForm" name="cform" method="post"> <div class="left"> <h1>Insurance Details</h1> <label>Type of Cover:</label> . . . <span class="gender-missing"><br />Please select your gender.<br /></span> <label>Gender:</label> <input class="radio" id="gender" name="gender" type="radio" value="Male" /> Male <input class="radio" id="gender" name="gender" type="radio" value="Female" /> Female Script.js: $('.contactForm').submit( function(){ //statements to validate the form var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; var digitNum = /^([0-9])/; var num1 = document.getElementById('tel'); var num2 = document.getElementById('mobile'); var email = document.getElementById('email'); var dollarUnit = document.getElementById('amount_cover'); var gender = document.getElementsById('gender'); if((document.cform.gender[0].checked== false)&&(document.cform.gender[1].checked== false)) {$('.gender-missing').show(); } else {$('.gender-missing').hide();} if((document.cform.smoke[0].checked== false)&&(document.cform.smoke[1].checked== false)) {$('.smoke-missing').show(); } else {$('.smoke-missing').hide();} if((document.cform.residency[0].checked== false)&&(document.cform.residency[1].checked== false)) {$('.residency-missing').show(); } else {$('.residency-missing').hide();} if (!filter.test(email.value)) { $('.email-missing').show(); } else {$('.email-missing').hide();} if (document.cform.name.value == "") { $('.name-missing').show(); } else {$('.name-missing').hide();} if (document.cform.address.value == "") { $('.address-missing').show(); } else {$('.address-missing').hide();} if (!digitNum.test(num1.value)) { $('.tel-missing').show(); } else {$('.tel-missing').hide();} if (!digitNum.test(num2.value)) { $('.mobile-missing').show(); } else {$('.mobile-missing').hide();} if (!digitNum.test(dollarUnit.value)) { $('.cover-missing').show(); } else {$('.cover-missing').hide();} if (document.cform.message.value == "") { $('.message-missing').show(); } else {$('.message-missing').hide();} if ((document.cform.name.value == "") || ((document.cform.gender[0].checked== false) && (document.cform.gender[1].checked== false)) || ((document.cform.smoke[0].checked== false) && (document.cform.smoke[1].checked== false)) || ((document.cform.residency[0].checked== false) && (document.cform.residency[1].checked== false)) || (!digitNum.test(dollarUnit.value)) || (!filter.test(email.value)) || (!digitNum.test(num2.value)) || (!digitNum.test(num1.value)) || (document.cform.message.value == "")){ return false; } if ((document.cform.name.value != "") && ((document.cform.gender[0].checked == true) || (document.cform.gender[1].checked == true)) && ((document.cform.smoke[0].checked== true) || (document.cform.smoke[1].checked== true)) && ((document.cform.residency[0].checked== true) || (document.cform.residency[1].checked== true)) && (digitNum.test(dollarUnit.value)) && (digitNum.test(num1.value)) && (digitNum.test(num2.value)) && (filter.test(email.value)) && (document.cform.message.value != "")) { //hide the form $('.contactForm').hide(); //show the loading bar $('.loader').append($('.bar')); $('.bar').css({display:'block'}); //send the ajax request $.post('mail.php',{coverType:$('#coverType').val(), coverRequired:$('#coverRequired').val(), amount_cover:$('#amount_cover').val(), terms:$('#terms').val(), message:$('#message').val(), name:$('#name').val(), gender:$('#gender').val(), status:$('#status').val(), Birth_month:$('#Birth_month').val(), days:$('#days').val(), years:$('#years').val(), smoke:$('#smoke').val(), residency:$('#residency').val(), email:$('#email').val(), address:$('#address').val(), tel:$('#tel').val(), mobile:$('#mobile').val()}, //return the data function(data){ //hide the graphic $('.bar').css({display:'none'}); $('.loader').append(data); }); //waits 2000, then closes the form and fades out setTimeout('$("#backgroundPopup").fadeOut("slow"); $("#contactForm").slideUp("slow")', 5000); setTimeout('$(".contact").animate({"marginLeft": "-=963px"}, "slow")',4900); //stay on the page return false; } }); //only need force for IE6 $("#backgroundPopup").css({ "height": document.documentElement.clientHeight }); mail.php code: <?php //declare our variables $coverType = $_POST['coverType']; $coverRequired = $_POST['coverRequired']; $amount_cover = $_POST['amount_cover']; $terms = $_POST['terms']; $message = stripslashes(nl2br($_POST['message'])); $name = $_POST['name']; $gender = $_POST['gender']; $status = $_POST['status']; $Birth_month = $_POST['Birth_month']; $days = $_POST['days']; $years = $_POST['years']; $smoke = $_POST['smoke']; $residency = $_POST['residency']; $email = $_POST['email']; $address = $_POST['address']; $tel = $_POST['tel']; $mobile = $_POST['mobile']; //get todays date $todayis = date("l, F j, Y, g:i a") ; //set a title for the message $subject = "Message from Your Website"; $body = "PERSONAL DETAILS \nFull Name: $name \nGender: $gender \nMarital Status: $status \nBirth Date: $Birth_month $days, $years \nHave you smoke in the past 12 Months? $smoke \nU.S. Residency for at least 12 Months? $residency \n\nCONTACT DETAILS\nEmail Address: $email \nAddress: $address \nTelephone #: $tel \nMobile Number: $mobile \n\nINSURANCE DETAILS\nCover Type: $coverType \nCover Required: $coverRequired \nAmount: $amount_cover \nTerms(Years): $terms \nMessage: \n$message"; $headers = 'From: '.$email.'' . "\r\n" . 'Reply-To: '.$email.'' . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); //put your email address here mail("me@myemail.com", $subject, $body, $headers); ?> <!--Display a thankyou message in the callback --> <div id="mail_response"> <h3>Thank you for your interest <?php echo $name ?>!</h3><br /> <p>We have received your personal information and we will forward it to the next available insurance agent .You can expect to hear from us within 24 hours.</p> <br /><br /> <h5>Message sent on: </h5> <p><?php echo $todayis ?></p> </div> Problem is the thank you message loads in a new page. BUt if I delete this line: var gender = document.getElementsById('gender'); The form run properly, when submit button is click, it will hide the forms and replace by a thank you message but problem is the data send in the email is not the right value eg. in Gender: I select Female. BUt I receive Male as value. Why is that? for live demo: http://gbv.lifeandhealthbenefits.com/ for full Script Code: http://gbv.lifeandhealthbenefits.com/js/scripts.js Hello. I am a new user. I have got a website, www.eastbourneinks.co.uk where the quantity buttons (+) & (-) do not work on most computers where I have had feedback. Is there any way of making them work on any/all computers. This is one of the pages: http://eastbourneinks.co.uk/product/...nk-cartridges/ Many thanks. Phil. how can i make a button that takes the user to the top of the page without the url#top being displayed in addy bar? i just dont like the way it looks thanks peeps On my website I have a radio button as any other normal radio button. <input type="radio" name="crime" value="4" id="4" class="submit"> is there any way to get rid of this radio button and click something for example <tr> <td>Blah blah</td> <td>Blah Blah</td> </tr> is there any code i can put in the <tr> tag so if i click that section it will act as a radio button and when its selected change the background of the tr section. Im trying to configuere a form that a. a radio buttons that allow the user to choose between quarters, nickels, dimes and pennies. and show image when click on my radio button im confused on how to get the image to display whenthey click on the radio button I've been looking around and all the validation stuff I've seen doesn't work for what I have. Here is what I am trying to do: The user selects the Heads or Tails radio button for the first flip and then selects heads or tails radio button for the 2nd flip. The script then randomly flips two coins and compares it to what the user selected and if they are the same the user wins and if not then they lose. So there would be 4 buttons total, two Heads and two Tails. The first set of Heads and Tails needs to be assigned to "guess1" and the 2nd set is "guess2". So if the user clicks Tails for Flip1 and Heads for Flip2 then Tails is assigned to guess1 and Heads is assigned to guess2. Right now the script just assumes the user is selecting heads for both flips. Code: <html> <head> <title>Guess Two Coin Tosses</title> <script> function flip5(){ //Input var guess1 = document.getElementById('guess1').value var guess2 = document.getElementById('guess2').value var flip1 = Math.floor(Math.random() * 2) var flip2 = Math.floor(Math.random() * 2) var outcomes if (flip1 == 0) flip1 = 'Heads'; else flip1 = 'Tails'; if (flip2 == 0) flip2 = 'Heads'; else flip2 = 'Tails'; //Processing if (flip1.toUpperCase() == guess1.toUpperCase()) { if (flip2.toUpperCase() == guess2.toUpperCase()) outcomes = 'win win'; else outcomes = 'win lose'; } else { // here we lost the first if (flip2.toUpperCase() == guess2.toUpperCase()) outcomes = 'lose win'; else outcomes = 'lose lose'; } //Output document.getElementById('flip1').value = flip1 document.getElementById('flip2').value = flip2 document.getElementById('outcomes').value = outcomes } </script> </head> <body> <h3>Predict the Futu Guess Two Coin Flips</h3> Enter Heads for Heads, Tails for Tails! Case does not matter! <p/>Your Guess for Flip-1: <input type=radio id="guess1" size="5" value="Heads" />Heads <input type=radio id="guess1" size="5" value="Tails" />Tails <p/>Your Guess for Flip-2: <input type=radio id="guess2" size="5" value="Heads" />Heads <input type=radio id="guess2" size="5" value="Tails" />Tails <p/>Flip-1: <input type="text" id="flip1" size="5" value="???" /> <p/>Flip-2: <input type="text" id="flip2" size="5" value="???" /> <p/><input type="button" value="Flip Two!" onclick="flip5()" /> <p/>Outcomes: <input type="text" id="outcomes" size="20" value="" /> <hr> </body> </html> |