JavaScript - Problem With Insert Statement In Mysql4.0
Hi
I am using mysql4.0. Here i have used one syntax: Quote: create table vimal(Customer int(11)); INSERT INTO vimal(customer) VALUES (001); which works perfect in mysql5.0. But when i am trying to execute it in mysql4.0, it shows error : "1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '; INSERT INTO vimal(customer) VALUES (001)' at line 1" Can anybody there who can pull my hand to come out of this problem. Regards: Vimal kumar Srivastava Madhepura,India Similar TutorialsHi, I have a BMI calculator that records my height / weight and BMI and I can change it then it updates, I'd like to be able to add one for each day and show all in a loop here is my current JavaScript: Code: /*** **** INSERT INTO TABLE ** ***/ function prePopulate(){ BMIDB.transaction( function (transaction) { //Starter data when page is initialized var data = ['1','','14','0','0','']; transaction.executeSql("INSERT INTO page_settings(id, fname, age, height, weight, gender, date) VALUES (?, ?, ?, ?, ?, ?, ?)", [data[0], data[1], data[2], data[3], data[4], data[5], data[6]]); } ); } /*** **** UPDATE TABLE ** ***/ function updateSetting(){ BMIDB.transaction( function (transaction) { if($('#fname').val() != '') { var fname = $('#fname').val(); } else { var fname = ''; } var age = $('#age').val(); var height = $('#height').val(); var weight = $('#weight').val(); var gender = $('#gender').val(); var date = $('#date').val(); transaction.executeSql("UPDATE page_settings SET fname=?, age=?, height=?, weight=?, gender=?, date=? WHERE id = 1", [fname, age, height, weight, gender, date]); } ); selectAll(); } function selectAll(){ BMIDB.transaction( function (transaction) { transaction.executeSql("SELECT * FROM page_settings;", [], dataSelectHandler, errorHandler); } ); } function dataSelectHandler(transaction, results){ // Handle the results for (var i=0; i<results.rows.length; i++) { var row = results.rows.item(i); var newFeature = new Object(); newFeature.fname = row['fname']; newFeature.age = row['age']; newFeature.height = row['height']; newFeature.weight = row['weight']; newFeature.gender = row['gender']; newFeature.date = row['date']; newFeature.height2 = newFeature.height / 100 newFeature.BMI = newFeature.weight / (newFeature.height2 * newFeature.height2) BMI = newFeature.BMI; bmiresult = BMI.toFixed(3); $('body').css('font-family',newFeature.height); $('#content').html('<h4 id="your_weight">'+ newFeature.fname +' your BMI is: </h4><span>'+ bmiresult +'</span>'); if(newFeature.fname != '') { $('#greeting').html('Hi '+newFeature.fname+'!'); $('#fname').val(newFeature.fname); } $('#height').val(newFeature.height); $('select#age').find('option[value='+newFeature.age+']').attr('selected','selected'); $('#weight').val(newFeature.weight); $('select#gender').find('option[value='+newFeature.gender+']').attr('selected','selected'); } } /*** **** Save 'default' data into DB table ** ***/ function saveAll(){ prePopulate(1); } function errorHandler(transaction, error){ if (error.code==1){ // DB Table already exists } else { // Error is a human-readable string. console.log('Oops. Error was '+error.message+' (Code '+error.code+')'); } return false; } function nullDataHandler(){ console.log("SQL Query Succeeded"); } /*** **** SELECT DATA ** ***/ function selectAll(){ BMIDB.transaction( function (transaction) { transaction.executeSql("SELECT * FROM page_settings;", [], dataSelectHandler, errorHandler); } ); } Hello CodingForums. Im having problems making my hidden divs close and open how I want them to. I have one hidden div which opens and reveals and login area. but near the submit button I have a signup button and I want the login div to close and the sign up one to open but I can't get the login one to close. I'm sure you experts could fix this easily for me. Javascript: Code: <script language="javascript"> function toggle() { var ele = document.getElementById("loginbox"); var text = document.getElementById("displayText"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerHTML = "show"; } else { ele.style.display = "block"; text.innerHTML = "hide"; } } function signup() { var ele = document.getElementById("signup"); var login = document.getElementById("loginbox"); var text = document.getElementById("displayText"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerHTML = "show"; if(login.style.display == "block") { login.style.display = "none"; text.innerHTML = "hide"; } else { } } else { ele.style.display = "block"; text.innerHTML = "hide"; } } </script> Html: Code: <div id="signup" style="display: none"> <p> test </p> </div> <div id="loginbox" style="display: none"> <form id="loginscript" action="search.php" method="post"> <p>Your Username:<input type="text" name="Username" /></p> <p>Your Password:<input type="password" name="Passwrod" /></p> <input type="submit" class="hiddenbutton" value="login" /> <input type="reset" class="hiddenbutton" value="reset" /> <a href="javascript:signup();"><input type="button" class="hiddenbutton" value="signup" /></a> </form> </div> <a href="javascript:toggle();"><input type="submit" class="topbutton" name="login" value="Login In or Sign Up" /></a> I'm having a problem. All i want to happen is this: The program asks you what's up. It gives you a prompt and the prompt message tells you to say "nm" (it means nothing much) And the if statement is that if you put nm into that prompt, it'll display a message. However, when i put in the prompt, even if i put in a bogus message, it'll still display the if statement. What do i do? Here's my code. Code: <html> <head> <title> The nothing much page! </title> <script type="text/javascript"> var nmj; alert("what's up man?"); var nmj = prompt("say nm , it means nothing much"); if (nmj = "nm") { alert("What!? Nothing much!? Sounds boring.") } alert(nmj); </script> </head> <body> NOTHING MUCH? WHATTT!?!? </body> </html> I have a Javascript function that is highlighting the menu in one of my courses. I am having a problem getting into an If statement in some cases. Here is my code: Code: function hilightCurrent() { var nav = document.getElementById('nav'); if (nav == null) { return; } var checkIndex = hreftable[__currpage]; var aObj = nav.getElementsByTagName('a'); var found = false; while ((found == false) && (checkIndex > -1)){ for(j=0; j < aObj.length; j++) { if(aObj[j].href.indexOf(index[checkIndex].href)>=0) { aObj[j].className='active'; alert("parent tag = " + aObj[j].parentNode.parentNode.parentNode.tagName); if(aObj[j].parentNode.parentNode.parentNode.getElementsByTagName == 'li'){ aObj[j].parentNode.parentNode.parentNode.className='active'; aObj[j].parentNode.parentNode.parentNode.getElementsByTagName('a')[0].className='active'; } found = true; break; } } checkIndex--; } } The alert I have in there currently is returning LI in the case where I want to get into the IF statement right below it. So the alert comes back as LI and then I am checking if it is LI but for some reason it doesn't get into that if statement. Can anyone help or have any ideas? Thanks! Hello everyone, I am using javascript and I have a radio button that the user selects and I have a function to see which button was selected, but i'm trying to use the return of that if statement in another statement. Basically another part of the function is dependent on what the user selects in the radio button. Here is what I have so far (I have some things in there that might not work because i'm trying to figure out what works): Code: <script type="text/javascript"> function getSelectedRadio() { len = document.dates.dep.length // returns the array number of the selected radio button or -1 if no button is selected if (document.dates.dep[0]) { // if the button group is an array (one button is not an array) for (var i=0; i<len; i++) { if (document.dates.dep[i].checked) { return i } } } else { if (document.dates.dep.checked) { return 0; } // if the one button is checked, return zero } // if we get to this point, no radio button is selected return -1; } function Calculate() { var i = getSelectedRadio(); if (i == -1) { alert("Please select if Marine entered Delayed Entry Program"); } else { if (document.dates.dep[i]) { return document.dates.dep[i].value; } else { return document.dates.dep.value; } } if (document.dates.yearDEAF.value < 1985 && document.dates.monthDEAF.value < 01 && document.dates.dayDEAF.value < 01 && first return from above ) { document.dates.yearDEP.value = (document.dates.yearDEAF.value); document.dates.monthDEP.value = (document.dates.monthDEAF.value); document.dates.dayDEP.value = (document.dates.dayDEAF.value); document.dates.yearPEBD.value = (document.dates.yearDEAF.value); document.dates.monthPEBD.value = (document.dates.monthDEAF.value); document.dates.dayPEBD.value = (document.dates.dayDEAF.value); } else if (document.dates.yearDEAF.value < 1985 && document.dates.monthDEAF.value < 01 && document.dates.dayDEAF.value < 01 && second return from above ) { document.dates.yearPEBD.value = (document.dates.yearAFADBD.value); document.dates.monthPEBD.value = (document.dates.monthAFADBD.value); document.dates.dayPEBD.value = (document.dates.dayAFADBD.value); document.dates.yearDEP.value = "N/A"; document.dates.monthDEP.value = "N/A"; document.dates.dayDEP.value = "N/A"; } } </script> I color coded in red the returns i'm trying to reference and where they need to be. Is this possible, and if so how can I do it? I haven't been able to find anything on the internet so far. Any help is greatly appreciated! No matter what first name and last name I enter I get "Wrong!" I get wrong if I enter john smith or bill shaw Code: <html> <head> </head> <body> <script type="text/javascript"> var input; var first; var last; input = window.prompt("Please Enter First and Last Name (e.g. Joe Smith)"); if ((first == "John" || first == "john") && (last == "Smith"|| last == "smith")){ document.write ("Welcome John Smith"); } if ((first == "Bill" || first == "bill") && (last == "Shaw"|| last == "Shaw")){ document.write ("Welcome Bill Shaw"); } else { document.write("Wrong!"); } </script> <body> </html> Hello CF im wondering how could i use an if statement to have something pop up when visitors visit my site that allows them two choices. it would say something like this. Would you Like to always see the navigation Bar? then they have two options. Yes and No. then depending on what they choose it will either have the code use the absolute or the fixed positioning attribute for the whole code. Or is this just not possible? If you want me to explain it more just ask. Hello, I have just started studying JS and don't know a whole lot about it. One exercise I have been given is to use the while statement to ask the user to guess a number between one and ten. this is the code I have attempted so far but it does not work. Simple for any one who is good at this. Impossible to me. Any takershttp://www.codingforums.com/images/smilies/confused.gif <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>While Test</title> <script type="text/javascript"> <!-- function whileTest(){ var number = 4; var answer = 0; while(number != answer ){ answer=prompt("Guesss a number between 1 and ten",""); } alert("4 is the correct answer") //--> </script> </head> <body onLoad="whileTest();"> </body> </html> Hi! I am a total newbie I'm afraid but I really enjoy learning javascript. Today I'm trying to write an if statement. I want the image1 on a web page to change when it's clicked to image2. Then I want the if statement to see if the source of the image is the changed image2.jpg (or still the original image1.jpg) and if it is the changed one I want another click to change it to image3. Here's my code, but the change to image 3 is not working: /* image change start */ var imgchanger = document.getElementById("changingimage"); imgchanger.onclick = function() { imgchanger.src = "image2.jpg"; }; /* image change 2 start */ if (imgchanger.src == "image2.jpg") { imgchanger.onclick = function() { imgchanger.src = "image3.jpg"; }; } I've got this code below to change an images source url based on the clicks from a dropdown menu. Is it possible to shorten this with some sort of if/or statement instead of all the else if's? something that says "if crenate or serrate or this or that, do this" here's the function: Code: function change3(picName,choice) { var url = (document[picName].src); if (/crenate\D{1}/.test(url)) { url = url.replace(/crenate/, choice) document[picName].src=(url); } else if (/margin_finelyserrate\D{1}/.test(url)) { url = url.replace(/margin_finelyserrate/, choice) document[picName].src=(url); } else if (/margin_lobed\D{1}/.test(url)) { url = url.replace(/margin_lobed/, choice) document[picName].src=(url); } else if (/margin_undulate\D{1}/.test(url)) { url = url.replace(/margin_undulate/, choice) document[picName].src=(url); } else if (/doubleserrate\D{1}/.test(url)) { url = url.replace(/doubleserrate/, choice) document[picName].src=(url); } else if (/leaf_shapes\D{1}/.test(url)) { url = url.replace(/leaf_shapes/,"leaf_shapes/" + choice) document[picName].src=(url); } } The dropdown menu just has options written like this: Code: <li id="margin1"><a href="javascript:passit4('entire')" onMouseover="change1('pic8','image34')" onclick="ShowContent('uniquename3'); change3('pic2','entire');" onMouseout="change1('pic8','image_off');">sample link (entire)</a></li> I'm not very familiar with java script at all, but could someone please explain how to make an if else else statement that follows these guidelines? 1. If the income is $70,000 or above the tax rate starts at 70% (the % sign will not show) 2. If the income is $20,000 or below the tax rate starts at 10% (the % sign will not show) 3. Otherwise the tax rate starts at 25% Thank you SO much! can someone help me with this pls: Code: function anything() { var tegenover = document.getElementById("minlas"); var septo = document.getElementById("combo_2"); //prijs verbinder per meter var serr = document.getElementById("comba_2"); //prijs verbinder per meter var seprr = document.getElementById("combb_2"); //prijs verbinder per meter var septrr = document.getElementById("combc_2"); //prijs verbinder per meter var nocho = document.getElementById("wide"); //breedte band in mm document.getElementById("totprijslas").value = Math.round(100*((parseFloat(septo.value) + parseFloat(serr.value) + parseFloat(seprr.value) + parseFloat(septrr.value)) * parseFloat(nocho.value))/1000)/100; } the value returned of totprijslas can be anything between 0 and 1000,but i want the value of "totprijslas" to be a minimum of "50",so for example if result is 30 then i need it to show 50.can someone help me with an if statement for this.thx Code: <script type="text/javascript"> var clicks=0; function linkClick(){ document.getElementById('clicked').value = ++clicks; if (clicks>2) { var answer = confirm ("What choice would you like?") if (answer) window.open("choiceA.html",'','scrollbars=no,menubar=no,height=600,width=800,resizable=no,toolbar=no,location=no,status=no') else (answer) window.open("choiceB.html",'','scrollbars=no,menubar=no,height=450,width=450,resizable=no,toolbar=no,location=no,status=no') } } </script> OR Code: <script type="text/javascript"> var clicks=0; function linkClick(){ document.getElementById('clicked').value = ++clicks; if (clicks>2) { var answer = confirm ("What choice would you like?") if (answer){ window.open("choiceA.html",'','scrollbars=no,menubar=no,height=600,width=800,resizable=no,toolbar=no,location=no,status=no') } else (answer) window.open("choiceB.html",'','scrollbars=no,menubar=no,height=450,width=450,resizable=no,toolbar=no,location=no,status=no') } } </script> OK, so now I'm trying so open a specific page depending on the users answer. I am aware that my code should look like this: Code: if (condition) { code to be executed if condition is true } else { code to be executed if condition is not true } However because of my click counter I have been unable to do this. My code itself does kinda work BUT choiceA open both choiceA and choiceB's pages :-( choiceB is fine and opens choiceB's page. I know that it's probably a small syntax error but I just can't see where. Thank-you in advance for your assistance. Code: function showResults( results ) { if ( results.length == 0 ) { msg = "no projects found"; } else {msg = results [0]; } document.getElementById("RESULTS").innerHTML = msg; //= results.join( "<br/>" ); cannot get it to show "no projects found" for 0 results and also to show all multiple results if multiple are found. works right now for 1 result but not multiple. the =results.join( "<br/>" ); works if multiple but then it will not say no projects found for 0 results. I want to know how I can update my power_points field if a select option is chosen. For example: if animal guardian is chosen Power_points - (attribute_level * 1) if combined attacks is chosen power_points - (attribute_level * 1) if elemental control is chosen power_points - (attribute_level * 3) etc... Here is my current script: Code: <?php session_start(); ?> <form> <table cellpadding="3" cellspacing="3"> <tr> <th>Attribute</th> <th>Level</th> <th>Power Points:</th> <th>Character Points:</th> </tr> <tr> <td><input type="text" readonly="readonly" value="Scout/Knight Powers" size="19" name="attribute1" /></td> <td><select name="level" onclick="power(), remain()"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> </select></td> <td align="center"><input type="text" name="power_points" id="power_points" size="1" readonly="readonly"/></td> <td align="center"><input type="text" name="cp_remain" id="cp_remain" size="1" readonly="readonly" /></td> </tr> </table> </form> <form method="POST" action="test_batosai.php"> <table><tr><td> <div id="dynamicInput1"> <table cellpadding="3" cellspacing="3"> <thead> <tr> <th>Sub-Attribute</th> <th>Level</th> <th>Notes <i>(optional)</i></th> </tr> </thead> <tbody> <tr> <td> <select name="attribute[]" size="1"> <option value="1">Animal Guardian</option> <option value="2">Combined Attacks</option> <option value="3">Elemental Control</option> <option value="4">Emotional Control</option> <option value="5">Item Of Power</option> <option value="6">Knight Attack</option> <option value="7">Rejuvenation</option> <option value="8">Sailor Scout Attack</option> </select></td> <td> <select name="attribute_level[]"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> </select></td> <td><textarea name="sub_notes[]" rows="1" cols="30"> </textarea></td> </tr> </tbody> </table> </div> <div id="cloneDiv1"> </div> </td> <td> <div id="dynamicInput2"> <table cellpadding="3" cellspacing="3"> <thead> <tr> <th>Neutral Attribute</th> <th>Level</th> <th>Notes <i>(optional)</i></th> </tr> </thead> <tbody> <tr> <td> <select name="attribute2[]" size="1"> <option value="1">Acrobatics</option> <option value="2">Appearance</option> <option value="3">Art Of Distraction</option> <option value="4">Combat Mastery</option> <option value="5">Damn Healthy!</option> <option value="6">Divine Relationship</option> <option value="7">Energy Bonus</option> <option value="8">Extra Attacks</option> <option value="9">Focused Combat</option> <option value="10">Fortified Body</option> <option value="11">Heightened Negaverse Power</option> <option value="12">Heightened Senses</option> <option value="13">Heightened Scout Powers</option> <option value="14">Massive Damage</option> <option value="15">Powerful Mind</option> <option value="16">Special Attack/Defense</option> <option value="17">Speed</option> <option value="18">Strong Soul</option> <option value="19">Supernatural Training</option> <option value="20">Unique Character Attribute</option> </select></td> <td> <select name="attribute_level2[]"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> </select></td> <td><textarea name="neutral_notes[]" rows="1" cols="30"> </textarea></td> </tr> </tbody> </table> </div> <div id="cloneDiv2"> </div> </td></tr></table> <input type="button" value="Add another Sub-Attribute" onClick="addInput('dynamicInput1','cloneDiv1');"> <input type="button" value="Add another Neutral Attribute" onClick="addInput('dynamicInput2','cloneDiv2');"> <input type="submit" /><input type="reset" /> </form> <script type="text/javascript"> var counter = 1; var limit = 10000000;// Set a limit if you want to function addInput(divFrom,divTo){ if (counter == limit) { alert("You have reached the limit of adding " + counter + " inputs"); } else { var newdiv = document.createElement('div'); newdiv.innerHTML = document.getElementById(divFrom).innerHTML; document.getElementById(divTo).appendChild(newdiv); counter++; } } //function for Power Points function power() { var first,res1; //Take the value of first textbox and convert it to float first=parseFloat(document.forms[0].level.value); res1=(first)*10; //show the result in the result textbox document.forms[0].power_points.value=res1; } //end function for Power Points //function for Character Points remaining function remain() { var first,res2; //Take the value of first textbox and convert it to float first=parseFloat(document.forms[0].level.value); res2=10-((first)*4); //show the result in the result textbox document.forms[0].cp_remain.value=res2; } //end function for Character Points </script> Can anyone help? I am relatively new to JavaScript coding, and I a having some problems with an IF statement. I want the IF statement to tell me when the number is below the minimum. Code: function main (txtpamphletMin,txtpamphletMax,optQuality,selIncrement,txtResults) { var txtpamphletMin,txtpamphletMax,optQuality,selIncrement; var amount = 100; var errorMsg = ""; var results = ""; pamphletMin = pamphletMin.value; //Make sure that the minimum number of pamphlets required is entered if (pamphletMin == "pamphletMin<100") { errorMsg = "Number of pamphlets must be above 100"; } else { pamphletMin = txtpamphletMin.value; //get the number of pamphlets from the text box errorMsg = validatepamphletMin(Minimum Pamphlets); } I know that this is no the entire statement but I am just having problems with this one. Can anyone help? I'm very new to javascript in general, but here's what I'm looking to do: I have a navigation link ("galleries") that 'onclick' displays a sub-menu of other links (the specific galleries). This is on the home page of my site. When a user first views the home page, the sub-menu does not display, until they click "galleries". On other pages of my site, the "galleries" link is one of the options in my navigation. That link takes users back to the home page which is what I want it to do. But what I'm looking for to happen is if the user is directed back to the home page from within another page on my site, I'd like the link on the homepage to automatically display the sublinks under the "gallery" link. This is so that users don't have to click "galleries" twice in order to see the submenu. For example: If a user is on the 'about me' page, in the navigation there is a 'galleries' link. If they click it, it takes them to the home page. They would then have to click on 'galleries' again on the home page in order to display the sub-menu of individual galleries. I want them to show up immediately, but only when directed back to the home page from within my site. I think I do that with an 'if' statement, but I'm not sure of the syntax. I know that's a bit wordy and a little round about but I hope you can understand what I mean. Feel free to ask any questions if I can clarify something for you. Hi, here is my code: Code: <script> $(window).load(function(){ var totalWidth = 0; $("#gallery img").each(function(){ totalWidth += $(this).outerWidth()+20; }); //alert(totalWidth); a = totalWidth+830; $('#content').css({'width' : a+'px'}); }); $('.back a').attr('href','#X'); $('.back a').click(function(){ var halfA = a/'3'; //alert(halfA); $('html, body').animate({scrollLeft: 0}, halfA); }); </script> on the line that reads: a = totalWidth+830; Is it possible to say something like: IF #content 'contains images' THEN a = totalWidth+430; ELSE a = totalWidth+830; OR the other way around: IF #content 'contains <p>' THEN a = totalWidth+830; ELSE a = totalWidth+430; I've got an annoying non-working bit of code: Code: <div id ="messageDiv" style="display:block;">No profile information entered yet</div> <script type="text/javascript"> function profileInfo() { var m1 = document.getElementById("marital1").innerHTML.toLowerCase(); var b1 = document.getElementById("bodytype1").innerHTML.toLowerCase(); var e1 = document.getElementById("ethnic1").innerHTML.toLowerCase(); var o1 = document.getElementById("occupation1").innerHTML; var w1 = document.getElementById("website1").innerHTML.toLowerCase(); var s1 = document.getElementById("smoker1").innerHTML.toLowerCase(); var d1 = document.getElementById("drinker1").innerHTML.toLowerCase(); var r1 = document.getElementById("religion1").innerHTML.toLowerCase(); if ((m1 == "no answer") && (b1 == "no answer") && (e1 == "no answer") && (o1 == "") && (w1 == '<a href=""></a>') && (s1 == "no answer") && (d1 == "no answer") && (r1 == "no answer")){ document.getElementById("messageDiv").style.display="block"; } else if ((m1 == "no answer") && (b1 == "no answer") && (e1 == "no answer") && (o1 == "") && (w1 == '<a href="http://">http://</a>') && (s1 == "no answer") && (d1 == "no answer") && (r1 == "no answer")){ document.getElementById("messageDiv").style.display="block"; } else { document.getElementById("messageDiv").style.display="none"; } } profileInfo() </script> The first part up to before the 'else if' works. but if the 'w1' has '<a href="http://">http://</a>' it still doesnt return true and display the DIV block?? Wrote this code out and it doesnt function correctly but I cannot see nefin wrong with it: <script type="text/javascript"> var choice; var startTag; var endTag; var validInput; var listType; choice = window.prompt("Select a list style:\n" + "1 (numbered), 2 (lettered), 3 (roman)", "1"); switch (choice) { case "1": startTag = "<ol>"; endTag = "</ol>"; listType = "<h1>Numbered List</h1>"; break; case "2": startTag = "<ol style = \"list-style-type: upper-alpha\">"; endTag = "</ol>"; listType = "<h1>Lettered List</h1>"; break; case "3": startTag = "<ol style = \"list-style-type: upper-roman\">"; endTag = "</ol>"; listType = "<h1> Roman Numbered List</h1>"; break; default: validInput = false; } if ( validInput == true ) { document.write(listType + startTag); for (var i = 1; i <= 3; ++i) document.write("<li>List Item " + i + " </li>" ); document.write(endTag); } else document.write("Invalid choice: " + choice); </script> |