JavaScript - Javascript Button With Css
Trying to build a timer for an image array, it works, I've created also a stopTimer on hover event. But, what I wish to do Is create buttons so the users can press previous or next and see the sliding images as they wish.
here'S my code so far : <script type="text/javascript"> var currPic=1; var totPics=8; var keepTime; function setupPicChange() { keepTime=setTimeout("changePic()", 15000); } function changePic() { currPic++; if(currPic>totPics) currPic=1; document.getElementById("picture").src="/images/services/picture"+currPic+".png"; setupPicChange(); } function stopTimer() { clearTimeout(keepTime); } function startTimer() { keepTime=setTimeout("changePic()", 5000); } function prevTimer() { currPic-1 } function nextTimer() {currPic+1} </script> I've created the nextTimer and prevTimer functions but they do not seem to work. I do not know how to integrated these functions in CSS sor my button, which are designed with CSS hover, down and active states... can you guys help me out ? am pretty basic here with codes... Similar TutorialsHey guys. This is vague because I dont know what exactly to tell you but please reply with me so I can fix this. I want to add something to my forum. Specifically, I want to add a HTML and Picture button for when you go to reply. Like posting an article here, there are also these options (font, alignment, insert image) I do not know how to achieve this but shouldnt be too hard. Here are the two sources you will need to look through to help me fix the forum. http://neoweather.com/FWFORUM.JS http://static.websimages.com/JS/fw.js THANKS Hi, I am not entirely sure what I am doing wrong here, and I have been looking at this for ages, so apologies in advance if I have become so bleary eyed I can't see something simple. I use php to create buttons based on values pulled for a table. The problem I have is when you click on the first button the javascript function works great, when you click on the next button you get the same output even though it should be different results. I am working in ff and I can see on my firebug console that the javascript function is being called, but it is not passing the new value of the second or third button, it just keeps repassing the value of the first button. So not entirely sure where I am going wrong here. My page is: Code: <script type="text/javascript"> function loadXMLDoc2(File,ID,Msg){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; } } var params=Msg; xmlhttp.open("POST",File,true); xmlhttp.setRequestHeader("Pragma", "Cache-Control:no-cache"); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); } </script> <head> <body> <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); $result = mysql_query("SELECT DISTINCT theme FROM goods WHERE category='{$_POST['category']}' ORDER BY theme DESC"); while($row = mysql_fetch_array($result)){ echo '<input type="text" class="hidden" name="theme" id="theme" value="' . $row['theme'] . '" ><input type="button" class="button3" name="product" id="product" value="' . $row['product'] . '" onClick="loadXMLDoc2(\'getShow.php\',\'txtHint\',\'theme=\'+encodeURI(document.getElementById(\'rtheme\').value))" > '; } echo '<br /><br /> <div id="txtHint"><div> <br /> <br />'; mysql_close($con); ?> And getShow.php produces a table with a list of product images, names and prices, based on theme. So basically not sure where I am going wrong here? Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks hello everyone I am working on a quiz which marks the user and displays to different screens when the total has been calculated. If the user gets over 80% a congratulations page is shown but if you score less your told to go back and look at some of the material again. I would like the congratulations page to show a button to let the users continue on to the next section of the tutorial. Does any one have any ideas how I could do this? im stumped. I have inserted the code below, any help would be much appreciated as I'm a little stuck :/ Code: // Function to create arrays. function makeArray(len) { for (var i = 0; i < len; i++) this[i] = null; this.length = len; } // creates objects for this question. function makeQuestion(question, correctAnswer) { var args = makeQuestion.arguments; this.question = question; this.correctAnswer = correctAnswer; this.userAnswer = null; this.isCorrect = isCorrect; this.showForm = showForm; this.userChoices = new makeArray(args.length - 2); for (var i = 0; i < args.length - 2; i++) { this.userChoices[i] = args[i + 2]; } } // determins if the questions answered correctly function isCorrect() { if (this.correctAnswer == this.userAnswer) return true; else return false; } // Method to display contents of question object. function showForm(n) { //argument n is the number of the question. document.write((n + 1) + '. ' + this.question + '<BLOCKQUOTE><FORM>'); //n+1 = the number of the question in the array (has to add one because the array starts with 0 or the first question would be number 0, this question displays the questions text, blockquote off sets the answer making them indented. for (var i = 0; i < this.userChoices.length; i++) { //goes through the questions one by one. document.write('<INPUT TYPE = "RADIO" NAME = "q' + n + //create the radio buttons. '" onClick = "quiz[' + n + '].userAnswer = ' + i + '">'); document.write(this.userChoices[i] + '<BR>'); } document.write('</FORM></BLOCKQUOTE>'); } // This corrects the quiz, dispays the correct answers and the score. function correctQuiz() { var correct = 0; // sets the correct page to a score of zero correctPage = '<HTML><TITLE>Corrections</TITLE><BODY BGCOLOR = "#FFFFFF">'; // sets the attributes of the correction page for (var i = 0; i < quiz.length; i++) { //loop runs through questions if (quiz[i].isCorrect()) correct++; // the is correct starts at 0 every time is correct returns true (an answer is correct) it adds 1 to the number adding up correct answers. } var score = Math.round((correct / quiz.length) * 100); // find out the % of correct answers by using math and the % equation correctPage += 'Sco <STRONG>' + score + '</STRONG> %'; if (correct < (quiz.length / 100) * 80) { //if the correct number is less than the quiz length then not all the answers were correct if it is the same then all ansers were correct. correctPage += ifWrong; // if there were wrong answers for (var i = 0; i < quiz.length; i++) { // starts a for loop through the answers if (!quiz[i].isCorrect()) { // if quiz doesn't = to iscorrect. correctPage += (i + 1) + '. ' + // this shows what number was wrong. quiz[i].userChoices[quiz[i].correctAnswer] + '<BR>'; // displays the correct answes for the questions that were wrong } } } else correctPage += ifAced; // this is the correct page displayed if all the answers were right. correctPage += '</BODY></HTML>'; // opens the window of correct page correctwin = window.open ('', '', 'height=300,width=300,scrollbars=yes'); if (correctwin.opener == null) correctwin.opener = window; correctwin.location = 'javascript:opener.correctPage'; } // Message to display if quiz is aced. var ifAced = "<P>Well done! you have passed the test. You can now move on to the next section of the tutorial<P>"; // Message to display if any are wrong. var ifWrong = "<P>Check below to see the answers that you got wrong. It maybe helpful if you go back and read the bits your unsure of.<P>"; // Create seven question objects... quiz = new makeArray(8); // this is how many questions there is in the quiz quiz[0] = new makeQuestion("What is the correct name for the leg marking found in picture 1?", // 1st question starts at 0 because thats the first number in an array 2, // correct answer "Sock", // choice 0 "Stocking", // choice 1 "Coronet band", // choice 2 "half cannon"); // choice 3 quiz[1] = new makeQuestion("What is the correct name for the leg marking found in picture 2?", // 2nd question 0, // correct answer "Sock", // choice 0 "Stocking", // choice 1 "Coronet band", //choice 2 "half cannon"); //choice 3 quiz[2] = new makeQuestion("What is the correct name for the leg marking found in picture 3?", 1, // correct answer "Sock", // choice 0 "Stocking", // choice 1 "Coronet band", //choice 2 "half cannon"); quiz[3] = new makeQuestion("What is the correct name for the leg marking found in picture 4?", 3, // correct answer "Sock", // choice 0 "Stocking", // choice 1 "Coronet band", //choice 2 "half cannon"); quiz[4] = new makeQuestion("What is the correct name for the face marking found in picture 5?", 2, "Bald", "Star", "Snip", "Blaze"); quiz[5] = new makeQuestion("what is the correct name for the face marking found in picture 6?", 0, "Bald", "Star", "Snip", "Blaze"); quiz[6] = new makeQuestion("what is the correct name for the face marking found in picture 7?", 3, "Bald", "Star", "Snip", "Blaze"); quiz[7] = new makeQuestion("what is the correct name for the face marking found in picture 8?", 1, "Bald", "Star", "Snip", "Blaze"); i am trying to achieve a JS driven button for a cms. for example i have a text in a textarea so i select the text and add the bold attribute to this text. my text before : text my text with bold added : <b>text</b> what the function to achieve this ? thanks when creating a button with javascript, is it possible to change the blue color when you mouse over it? I know its a stupid question but I am curious... I'm new to this javascript stuff..
I have a basic Javascript slideshow that flicks through a series of 6 jpg images very quickly. I also have a button that i need coded so that when a user clicks on the button, the script for the slide show slows down the speed of the flicking images slowly over the coarse of ten seconds and stops on an image. How do i go about coding the button in javascript? I hope this makes sense. Thankyou Here is my code so far. var i, imgs, pic; function rotate() { pic.src=imgs[i]; (i===(imgs.length -1))? i=0:i++; setTimeout(rotate,500); } function diceroll() { pic=document.getElementById("yes"); imgs=["photo1.jpg", "photo2.jpg","photo3.jpg","photo4.jpg","photo5.jpg"]; var preload=new Array(); for(i=0;i<imgs.length;i++) { preload[i]=new Image(); preload[i].src=imgs[i]; } i=0; rotate(); } For school I'm supposed to write a JS code which visits a website, and then clicks on a button on that website. I used the document.location method to visit the web page, but then if I use the document.forms[0].elements[0].click() function to click a button, nothing happens. The click() function has always worked for me when the JS code is embedded in the web page, but its not in this case because the code has to click a button on an external website. So how can I do this? I just need me Javscript program to visit a site, and then click a button on that site. Please help, thanks.
Good afternoon. I'm trying to make it so a 'radio button' in a 'form' will 'collapse' a Div that I have hidden. I'm using the JavaScript to control the collapse, and google's Jquery for the rest of it. here's the code. Code: <head> <script type="text/javascript" src="SpryAssets/collapse.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> animatedcollapse.addDiv('test', 'fade=1, group=test, speed=400') animatedcollapse.ontoggle=function($, divobj, state) { //fires each time a DIV is expanded/contracted //$: Access to Jquery //divobj: DOM reference to DIV being expanded/collapsed. Use "divobj.id" to get the ID. //state: "block" or "none", depending on the state. } animatedcollapse.init() </script> </head> and the body code... Code: <form action="myform.php" method="post"> <a id="collapsable" href="javascript:animatedcollapse.toggle('test')"> [+] Testing the Collapsability of this Scripting.</a> <div id="test" style="display:none;"> <h1> You can see that if you toggle the 'Image Display' Button. This will display Properly.</h1> </div> </form> You can find a completely working version (When not using Radio buttons and forms) located at My Toggle Works Here. Alternatively, you can find the NON working version, which is what I'm attempting to get to work, located at My Toggle Doesn't Work. you can see that in the version that doesn't work, if you hit the 'Radio button', it will collapse, and immediately uncollapse the Div, I don't get why it does this. Any help is greatly appreciated. Hi all. Can someone tell me why I can select both HTML AND another radio button, but when I unselect, and select a # of 1 through 4, I can switch between the radio buttons, but I can't if I select HTML first? Also, what's wrong w/ this code? Code: <html> <head> <title>Webpage Teacher - V 1.0</title> </head> <body> <script> // set the radio button with the given value as being checked // do nothing if there are no radio buttons // if the given value does not exist, all the radio buttons // are reset to unchecked function setCheckedValue(radioObj, newValue) { if(!radioObj) return; var radioLength = radioObj.length; if(radioLength == undefined) { radioObj.checked = (radioObj.value == newValue.toString()); return; } for(var i = 0; i < radioLength; i++) { radioObj[i].checked = false; if(radioObj[i].value == newValue.toString()) { radioObj[i].checked = true; } } } function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } </script> <form name="radioExampleForm" method="get" action=""> <p> <label for="code1"><input type="radio" value="HTML" name="code" id="code1"> HTML</label> <label for="number0"><input type="radio" value="0" name="number" id="number0"> Zero</label> <label for="number1"><input type="radio" value="1" name="number" id="number1"> One</label> <label for="number2"><input type="radio" value="2" name="number" id="number2"> Two</label> <label for="number3"><input type="radio" value="3" name="number" id="number3"> Three</label> <label for="number4"><input type="radio" value="4" name="number" id="number4"> Four</label> </p> <p> <script> var thevar=''; if(document.forms['radioExampleForm'].elements['number']){ thevar='number'; }else{ thevar='code'; } document.write('' +'<input type="button" onclick="alert(\'Checked value is: '+getCheckedValue(document.forms[\'radioExampleForm\'].elements[\''+thevar+'\']));" value="Show Checked Value">'); </script> <input type="button" onclick="setCheckedValue(document.forms['radioExampleForm'].elements['code'], 'HTML');" value="Set Checked to HTML"> <input type="button" onclick="setCheckedValue(document.forms['radioExampleForm'].elements['number'], '1');" value="Set Checked to One"> <input type="button" onclick="setCheckedValue(document.forms['radioExampleForm'].elements['number'], '2');" value="Set Checked to Two"> <input type="button" onclick="setCheckedValue(document.forms['radioExampleForm'].elements['number'], '3');" value="Set Checked to Three"> <input type="button" onclick="setCheckedValue(document.forms['radioExampleForm'].elements['number'], '4');" value="Set Checked to Four"> <input type="button" onclick="setCheckedValue(document.forms['radioExampleForm'].elements['number'], ''),setCheckedValue(document.forms['radioExampleForm'].elements['code'],'');" value="Uncheck All"> </p> </form> </body> </html> I simply want it to display the Check Value button and detect 2 different id's for 2 different radio buttons (which is 'code' and 'number') Thanks! Hello, I am trying to implement a radio button option so that users can search specific sites such as google, yahoo, or bing from input box. Here's my code. Please help. <script type="text/javascript"> <!-- function goSearch(){ //search according to checked radio button } --> </script> <h1>Search Option</h1><br /> <input type="radio" name="search" id="google"/><a href="http://www.google.com" rel="nofollow" target="_blank"><img src="images/google.jpg" /></a> <input type="radio" name="search" id="yahoo"/><a href="http://www.yahoo.com" rel="nofollow" target="_blank"><img src="images/yahoo.jpg" /> </a> <input type="radio" name="search" id="bing" /><a href="http://www.bing.com" rel="nofollow" target="_blank"><img src="images/bing.jpg" /> </a> <br /><br /> <form method="get" action="goSearch()" rel="nofollow" target="_blank"> <div style="border:1px solid black;padding:4px;width:20em;"> <table border="0" cellpadding="0"> <tr> <td> <input type="text" name="q" size="25" maxlength="255" value="" /> <input type="submit" value="Search" /> </td> </tr> </table> </div> </form> I'm trying to make radiobuttons with a javascript function that gets called when a button is selected to make an image appear depending on what they click. However, after looking it up for a while I have nothing since some tell me to do document.formName.name.value; some tell me to use an id with my buttons and just use a document.getElementByID(""); etc. This is for a project and we havent used parameters yet and I dont know how to implement them in the HTML as well This is my code: function classchoice() { if(document.getElementById('mage') == true) { classtype = "<img class='display' src='mage.jpg'>"; document.getElementById("picture").innerHTML=classtype; } if(document.classes.classes.paladin == true) { classtype = "<img class='display' src='paladin.jpg'>"; document.getElementById("picture").innerHTML=classtype; } if(document.classes.classes.hunter == true) { classtype = "<img class='display' src='hunter.jpg'>"; document.getElementById("picture").innerHTML=classtype; } if(document.classes.classes.rogue == true) { classtype = "<img class='display' src='rogue.jpg'>"; document.getElementById("picture").innerHTML=classtype; } } This is the HTML: <form name="classes"> <input type="radio" name = "classes" id="mage" onmousedown="classChoice();"> <img src = "mage.jpg" /> <input type="radio" name = "classes" id = "Paladin" onmousedown="classChoice();"> <img src = "Paladin.png" /> <input type="radio" name = "classes" id = "hunter" onmousedown="classChoice();"> <img src = "hunter.PNG" /> <input type="radio" name = "classes" id = "rogue" onmousedown="classChoice();"> <img src = "rogue.jpg" /> </form> I hope it's readable because I copy and pasted my code and the indentations are a bit messed up Hey everyone I want to go ahead and say my issue with javascript is in a homework assignment so...I'm just looking to get more of a nudge in the right direction of how to fix this issue than anything ^^' I'm not asking to have the code fixed for me. I've been assigned to code a simple currency converter of just US dollars to a few other kinds of currency. I have most of the basic stuff done, I used an example piece of javascript and am editing it to try and make it into what I need. I'm just having issues with the button that is supposed to run the function and output the value of the currency, I can't seem to get the button to work. Here is the code I've gotten so far, if someone could just point out maybe where the issue is as sort of a hint I'd be really grateful! Code: <html> <head> <title>Currency Converter</title> <script type = "text/javascript"> function calcvalue() { if (CurrencyType == "USDollars") {price = 1;} if (CurrencyType == "BritishPounds") {price = 0.632766;} if (CurrencyType == "Euros") {price = '.709723';} if (CurrencyType == "CanadianDollars") {price = 0.970476;} if (CurrencyType == "JapaneeseYen") {price = 83.073;} if (CurrencyType == "ChineeseYuan") {price = 6.55649; Currency.answer.value=price*DollarAmount; } if (!( DollarAmount >= 1001 || DollarAmount <= 0)) { alert ("Please Enter a value between 1 and 1000"); return; } } </script> <body> <body bgcolor="CCCCFF"> <form name="Currency"> <center> <table> <tr> <td>Currency Type: </td> <td> <select name="Currency"> <option value="USDollars">US Dollars</option> <option value="BritishPounds">British Pounds</option> <option value="Euros">Euros</option> <option value="CanadianDollars">Canadian Dollars</option> <option value="JapaneeseYen">Japaneese Yen</option> <option value="ChineeseYuan">Chineese Yuan</option> </select> <tr> <td>Dollar Amount</td> <td> $<input type=parsefloat() value="1" name="DollarAmount" size=3></td> </tr> <tr> <td> </td> <td><p class="submit"> <input type=button value="Convert" onclick=calcvalue()></p></td> </tr> <tr> <td>value:</td> <td><input type=text size=6 name="answer"><td> </tr> </table> </center> </form> </body> </html> Okay, I'm good at PHP but using javascript so the user doesnt need to refresh the page is a neat thing. I want to make a button that says "Do you like this game? Yes or No" How can I use javascript to tell Yes to send games->rating_yes = 1 or No games->rating_no = 1 Or if you could link me with resource on building something that can teach me how to use javascript to update/insert into my database. I've tried stuff like this Code: Do you like this game? <a href="javascript://" onclick="ajaxYESorNO('<?=$gameid;?>','like');">Yes</a> or <a href="javascript://" onclick="ajaxYESorNO('<?=$gameid;?>','dislike');">No</a> Code: function ajaxYESorNO(gameid,answer) { ajax = ajaxFunction(); ajax.onreadystatechange = function () { ajaxRateGame_stateChanged(vote); }; var url = base_url+ "includes/ajaxYESorNO.php"; url = url+ "?vote=" +answer; url = url+ "&gameid=" +gameid; ajax.open("GET",url,true); ajax.send(null); } PHP Code: <?php $gameid = $_GET[gameid]; $vote = $_GET[vote]; @include "config.php"; if($_GET['vote']=='like') { $result = $GLOBALS['dFetch']->exec ("update games set rate_yes=rate_yes+1 where gameid = $gameid"); } else { $result = $GLOBALS['dFetch']->exec ("update games set rate_no=rate_no+1 where gameid = $gameid"); } ?> But yet cant seem to figure how to get it working properly Thanks. Hi I've set up an html page that contains 3 buttons, which have a sprite rollover effect when hovered over. This is handled by css. When one of the buttons is clicked - a value is passed to an input field. This is handled by Javascript. Both of these functions work. What I would like to do is add a second function when a button is clicked - so that the hover sprite remains selected. Could anyone tell me how to do this please? Here is the button code I have: <button type="button" class="fantasy_button_blue_sprite" id="mcgyver" value="mcgyver" onclick="setHiddenControlValue('option1');">next</button> Here is the input field that gets populated: <input type="<?php echo $type;?>" id="fantasy_friend" name="fantasy_friend" value="<?php echo $fantasy_friend; ?>"> This is the javascript I'm using: <!-- // set the hidden form field when a button is clicked function setHiddenControlValue(selectedValue) { document.getElementById("fantasy_friend").value = selectedValue; parent.document.options_form.their_firstname.value=selectedValue; } And this is the sprite css: .fantasy_button_green_sprite { background: transparent url("/images/align_page/fantasy_button1.jpg") 0 1px no-repeat; height:61px; width:164px; border:none; text-indent:-99999px; cursor: pointer; margin-top:20px; } .fantasy_button_green_sprite:hover { background: transparent url("/images/align_page/fantasy_button1.jpg") 0 -61px no-repeat; } Thanks! Tom --> Can someone explain to me as to why the "New Art" button in the navigation doesn't have the "on" function as the others where you hover over the button and the text turns orange? Keep in mind, I didn't design/develop this site...I'm merely just trying to insert a button in the nav for a friend of mine. Thanks for your help it is greatly appreciated! Here's the website: http://www.thejam2.com/two/ And the code: Code: } menuImage = {}; function makeMenu(){ var imgs = ["thejam", "newart", "theartist","viewit","orderit","theCollage","theBorder","detailedImages","theMusicians"]; for(i in imgs){ menuImage[imgs[i]+"off"] = new Image(); menuImage[imgs[i]+"off"].src = "pics/menu_"+imgs[i]+".gif"; menuImage[imgs[i]+"on"] = new Image(); menuImage[imgs[i]+"on"].src = "pics/menu_"+imgs[i]+"_on.gif"; } document.write('<div id="menu"><table width="'+((ns4) ? 794 : '100%')+'" cellpadding=0 cellspacing=0 border=0>'); if(ns4) document.write('<tr><td><img src="pics/spacer.gif" width="418" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td></tr>'); document.write('<tr><td width="100%"> </td>'); document.write('<td width="94" background="pics/button_guitarBig.gif" width="75">' + makeButton('bios.php?artist=about','thejam','jamMenu') + '<br></td>'); document.write('<td width="94" background="pics/button_starBig.gif" width="75">' + makeButton('newart.php','newart','newart') + '<br></td>'); document.write('<td width="94" background="pics/button_guitarBig.gif" width="75">' + makeButton('bios.php?artist=mike_keirstead','theartist') + '<br></td>'); document.write('<td width="94" background="pics/button_starBig.gif" width="75">' + makeButton('jam2.php','viewit','viewMenu') + '</td>'); document.write('<td width="94" background="pics/button_guitarBig.gif" width="75">' + makeButton('jam2.php?loc=order','orderit') + '</td></tr>'); document.write('<tr><td> </td><td>'); makeJamMenu(); document.write('</td><td colspan="4" align="center">'); makeViewMenu(); document.write('</td></tr></table></div>'); } I am quite unexperienced in javascript (my only related experience is work with actionscript), so this problem is likely extremely simple. I am trying to alter a bit of code from a Firefox Jetpack extension (ClicktoFlash, if that helps) to suit my needs, and am having some trouble executing a time based event. The pertinent section of the extension's code is as follows: Code: placeHolder.click(function(eventObject){ $(this).replaceWith(jQuery.data( placeHolder, "myEmbed") ); }); The bit of code executed within the function is what I wish to maintain, but I want the code to instead be executed within a certain timeframe. My makeshift attempt to alter the code read like this: Code: var currentTime = new Date(); var hour = currentTime.getHours(); if((hour >= 2) && (hour < 7)){ $(this).replaceWith(jQuery.data( placeHolder, "myEmbed") ); }; This didn't work quite like I had hoped (though I think the code itself is solid), and I think under the circumstances I might need to replicate the placeHolder.click() segment while 7>hour>=2 for the code to execute properly; however, I am having quite a bit of trouble trying to do this. In short, is it possible to trigger a button press without the mouse ever clicking the button, or is there a glaringly apparent easier solution that I'm missing? Thanks in advance. Hello, First, thank you to anyone that can help. Basically I am trying to create a Cascade Dropdown with a submit button, that once clicked, takes them to a URL depending on the choices they made in the cascade dropdown. I have the cascade dropdown working properly but do not know how to create a submit button that says, "If Cookeville = Cosmetology; then go to this URL." Any ideas or suggestions? I will need to create this type of conditional statement for each choice. My code so far is below. Thank you again in advanced. Code: <form id="locations"> <label for="categories">categories: </label> <select name="categories" id="categories"> <option value="1">Cookeville, TN</option> <option value="2">Lebanon, TN</option> <option value="2">Dalton Beauty School</option> <option value="2">Daphnie</option> </select> <label for="items">items: </label> <select name="items" id="items" type="submit"> <option class="2" value="0">Cosmetology</option> <option class="2" value="1">Cosmetology Instructor</option> <option class="2" value="2">Instructor Trainee</option> <option class="1" value="3">Cosmetology</option> <option class="1" value="4">Cosmetology Instructor</option> <option class="1" value="5">Esthetician</option> <option class="1" value="6">Instructor Trainee</option> <option class="1" value="7">Nail Technology</option> </select></form> <script type="text/javascript"> //Applies cascading behavior for the specified dropdowns function applyCascadingDropdown(sourceId, targetId) { var source = document.getElementById(sourceId); var target = document.getElementById(targetId); if (source && target) { source.onchange = function() { displayOptionItemsByClass(target, source.value); } displayOptionItemsByClass(target, source.value); } } //Displays a subset of a dropdown's options function displayOptionItemsByClass(selectElement, className) { if (!selectElement.backup) { selectElement.backup = selectElement.cloneNode(true); } var options = selectElement.getElementsByTagName("option"); for(var i=0, length=options.length; i<length; i++) { selectElement.removeChild(options[0]); } var options = selectElement.backup.getElementsByTagName("option"); for(var i=0, length=options.length; i<length; i++) { if (options[i].className==className) selectElement.appendChild(options[i].cloneNode(true)); } } //Binds dropdowns function applyCascadingDropdowns() { applyCascadingDropdown("categories", "items"); //We could even bind items to another dropdown //applyCascadingDropdown("items", "foo"); } //execute when the page is ready window.onload=applyCascadingDropdowns; </script> I want to show an hourglass instead of a mouse pointer on click of a button. I'm having both client and server side validations on the button click event. I have written the code for hourglass in the javascript function along with the validations. Now, on click of the button the hourglass gets displayed after 3-4 seconds and not immediately. According to me, the hourglass is getting displayed after the javascript function(client side validation) is executed and before server side validation begins. Is there any way to display the hourglass without delays ? Kindly let me know if there is any fix for eliminating this delay. I hope my question is clear. Please let me know if i'm wrong somewhere as i'm new to javascript programming. Thanks in advance. zizou. I want to change radio button values dependent on the selected item in a drop down list. The radio buttons have default values but I need them to be changed when the selection has been made in the drop down list and before the submit button has been pressed so the changed values will be written to the database. Example : Drop down item : National Radio 1 value : Director Radio 2 value : National PA Drop down item : Regional Radio 1 value : Regional Manager Radio 2 value : Regional PA Drop down item : Local Radio 1 value : Store Manager Radio 2 value : Assistant Store Manager Any help will be appreciated. |