JavaScript - Newbie Want A Toggle Menu From An Array And I Want The Values To Be Hyperlinks
Hi there,
this is my first post so forgive me if it is frustrating to those who try to help. I am trying to create a side navigation menu that I want to just be a heading then once clicked it toggles on a list. Each item must be a link to a different webpage. so far i have only managed to create a toggle list but cannot control each item to make it a unique link. I'll post the script I have so far; -------------------------------------------------------------------------- <script language="javascript" type="text/javascript"> function list_colours() { var i=0; var colours = new Array(); colours[0]=<a href="../Yellow Inventory.html"> Yellow </a>; colours[1]=<a href="../Orange Inventory.html">"Orange"</a>; colours[2]=<a href="../Pink Inventory.html">"Pink"</a>; colours[3]=<a href="../Green Inventory.html">"Green"</a>; colours[4]=<a href="../Blue Inventory.html">"Blue"</a>; colours[5]=<a href="../Red Inventory.html">"Red"</a>; var text=""; for(var i=0; i < colours.length; i++) { text = text + colours[i] + "</a><br/>"; } return text; } //creating a toggle menu var onOff = "off" function insertText() { if(onOff == "off") { var paragraph = document.getElementById("colour-items"); var colours_list = list_colours(); paragraph.innerHTML=colours_list; onOff="on" } else { var paragraph = document.getElementById("colour-items"); var colours_list=""; paragraph.innerHTML=colours_list; onOff="off" } } </script> <div id="left-container"> <div id="Nav-title"><h3 onmouseover="insertText();">Colours</h3></div> <p id="colour-items"></p> </div> ------------------------------------------------------------------------- It is my guess that you make the array lists a list of a links, though I can't seem to find the correct way how. The second problem I have is that I have a large number of images of products on my page. I would like 4 headings that contain all my images, like the toggle menu above. so I click the heading and only those images come up. I will be happy to answer any questions that may help. Thanks all. Similar TutorialsFollowing are my script to toggle b/w two different links, <html lang="en-US"> <head> <title>toggle b/w 2 different links</title> <script type="text/javascript"><!-- display=1; function displayvalue() { document.getElementById("sv1").style.display = "block"; document.getElementById("dw1").style.display = "none"; } function ShowHide() { if (display==1) { document.getElementById("sv1").style.display = "none"; document.getElementById("dw1").style.display = "block"; //document.getElementById('javaFun') calling java func from javascript display=2; } else { document.getElementById("sv1").style.display = "block"; document.getElementById("dw1").style.display = "none"; //document.getElementById('javaFun1') calling java func from javascript display=1; } } function Func1Delay() { document.getElementById("sv1").style.display = "none"; document.getElementById("loadimage").innerHTML="<input type='image' src='Loading.gif'>"; setTimeout("LoadImage()", 300); } function LoadImage() { document.getElementById("loadimage").innerHTML=""; ShowHide(); } --></script> </head> <body background="GsNJNwuI-UM.gif"onload="displayvalue()"> <div id="sv1" > <a onclick ="Func1Delay()" href="javascript:;">click me</a> </div> <div id="loadimage"></div> <div id="dw1" > <a onclick ="ShowHide()" href="javascript:;">Download me</a> </div> </body> </html> whenever we call a java method , (consider this line:- document.getElementById('javaFun');)after the completion of java call the page is reloading, how control this reloading after the server completing the request....? Hi, here is what I am trying to do, mind if I sound simple this is my first major javascript attempt. You click the checkbox and it changes a link. You click the checkbox again and it changes it back. So you have a page with a link : <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RSNVHTY5D6RN" id="pay"><img src="go.gif"></a> and a checkbox : <a nohref style="cursorointer;color:blue;text-decoration:underline" onclick="changeTarget()"><input type="checkbox" OnClick="changeTarget()" checked="yes" name="opt-in" id="opt-in" align="center" /></a> </p> Clicking the checkbox runs the javascript function ChangeTarget(). Here is what I want the javascript to do: Code: 1. Write current pay value to variable 2. Compare variable to paypal link -3. change to clickbank link -else change to paypal link. Here is the code I have tried that doesnt work: Code: <script type="text/javascript"> var link = document.getElementById('pay'); function changeTarget() if(link == "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RSNVHTY5D6RN") document.getElementById('pay').href="http://1.60years.pay.clickbank.net"; else document.getElementById('pay').href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RSNVHTY5D6RN"; </script> Any help would be very much appreciated, I don't know why it isnt working. It just doesnt do anything when you click it. I know the following DOES work, but it only changes the link to the value chosen... no way of changing it back when you click the checkbox a second time. Code: //WORKING CODE <script type="text/javascript"> function changeTarget() { document.getElementById('pay').href="http://1.60years.pay.clickbank.net"; } </script> Hi all, I have a form where I want a single checkbox to toggle the selected/unselected status based on the status of that master checkbox. I have a working script that accomplishes this, but I'm having a problem now that I'm submitting the checkbox as an array. Here is the JS : Code: function checkAll() { if(document.resultForm.master.checked== true) { for(var i=0; i < document.resultForm.choices.length; i++) { document.resultForm.choices[i].checked=true; } } else { for(var i=0; i < document.resultForm.choices.length; i++) { document.resultForm.choices[i].checked=false; } } } Here is the form that it currently works with : Code: <input type="checkbox" name="master"> <input type="checkbox" name="choices" value="choice 1"> <input type="checkbox" name="choices" value="choice 2"> <input type="checkbox" name="choices" value="choice 3"> <input type="checkbox" name="choices" value="choice 4"> And this is the form that I want it to work with instead : Code: <input type="checkbox" name="master"> <input type="checkbox" name="choices[]" value="choice 1"> <input type="checkbox" name="choices[]" value="choice 2"> <input type="checkbox" name="choices[]" value="choice 3"> <input type="checkbox" name="choices[]" value="choice 4"> Any help would be greatly appreciated! Hi there! Okay, here is my scenario: I have a link and a div on a webpage. With the link I want to toggle the content (HTML) of the div. On toggle, I want to load the content from a PHP-file and I want it to load on the toggle, not when the webpage originally loaded (to reduce loading time on the webpage itself). The file that is loaded on toggle doesn't have to be PHP, but it would help a lot. Does anybody know of a example of this or something similar to it? I have been looking for some time now, without any luck unfortunately. Highly appreciate any help/answers/feedback! Hi guys, i am trying to work with google maps api my issue is with creating an array of markers count the number of marker, and then if it equal two, issue an error msg. i wrote some code, but that doesn't work obviously. and my question is how do i write that code in javascript ? GEvent.addListener(map, 'click', function (overlay, latlng) { if (placeMarker.length < 2) { pendingLatLng = latlng; setTimeout("settleClick()", 225) } else { message("You can only select 2 points."); } }); a sample click event which looks like the line below does work. what am i doing wrong ?: google.maps.event.addListener(map, 'click', function (event) {placeMarker(event.latLng); }) I am incorporating this menu into a site and for desktop users I need the mouseover. However, after referencing the link below for mobile devices (most management has Blackberrys). I am concerned the mouseover will not work on their phones. How do I add an option that will work on phones - like mouseover OR click option? http://www.quirksmode.org/m/table.html Thanks! I'm a newbie...please! html lists making javascript array I need help with a HTML UL I have ul inside ul but all I want to get when I select a certain list is the children of that list but remove the ul inside that list so they dont show at all http://pastebin.com/m98deaff any help would be great , current selecting code is http://pastebin.com/m6f4b886f Code: <div class="demo" id="demo_1"> <ul> <li id="1" class="open"><a id="1" href="#"><ins> </ins>Root node 1</a> <ul> <li id="2"><a id="2" href="#"><ins> </ins>Child node 1</a></li> <li id="3"><a id="3" href="#"><ins> </ins>Child node 2</a></li> <li id="4"><a id="4" href="#"><ins> </ins>Some other child node with longer text</a></li> <li id="6"><a id="6" href="#"><ins> </ins>Root node 222</a> //SHOUL NOT BE IN MY ARRAY <ul> <li id="7"><a id="7" href="#"><ins> </ins>Child node 222a</a></li> <li id="8"><a id="8" href="#"><ins> </ins>Child node 222b</a></li> <li id="9"><a id="9" href="#"><ins> </ins>Some other child node with longer text 222</a></li> </ul> //END OF UL ELEMENT N OT NEEDED THERE COULD BE more than 1 </li> </ul> </li> <li id="5"><a id="5" href="#"><ins> </ins>Root node 2</a></li> </ul> im trying to have it save the values in the menu, i was think either cookies or storing it in the .window thing but i am unsure of how to do these, any help would be great. Code: <script type="text/javascript"> function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(y); } } } <!-- // initialise shortcuts on page load var selectObj1=null, selectObj2=null// global function init() { selectObj1=document.getElementById("select_1"); selectObj2=document.getElementById("select_2"); selectObj2.disabled=true; // ========== end init() ============== // second select box options list var A= new Array() A["remote 1"]=["0","yup","DVD-1"]; A["remote 2"]=["0","VCR-1","DVD-2"]; // // global variables var saveObj=null, indx=null, targetObj=null, selectNo=null; // function process(obj,sNumb) { // disable unused select boxes if(sNumb==1) { selectObj1.selectedIndex="0"; selectObj1.disabled=true; } else if( sNumb==2) { selectObj1.selectedIndex="0"; selectObj1.disabled=true; } // // store selected index indx=obj.options.selectedIndex; // invalid selection if(indx==0){ return; } // --------- // save passed parameters for use after timeout deleay saveObj=obj, selectNo=sNumb; // put object items list into next select box after clearing targetObj=document.getElementById("select_"+selectNo) targetObj.disabled=false; // clear any existing options note that this starts from end of list, not beginning for(var i=targetObj.options.length-1;i>-1;i--) { targetObj.options[i]=null; } // build in short delay here to avoid error in Opera browser setTimeout("finishOff()",50) } // ----------- 50ms delay here -------- // called from timeout in function process() function finishOff() { var obj=saveObj; // from global // fill selectObj options var i, thisItem=0; // build options list switch(selectNo){ case 2 : targArray = A[obj.options[indx].value]; break; } // for(i=0;i<targArray.length;i++) { thisItem=targArray[i]; // syntax is new Option("text", "value", isDefaultSelectedFlag, isSelectedFlag) targetObj.options[i]=new Option(thisItem,thisItem,false,false); } obj.blur(); } // ============ end process() =================== // fires on selecting in third select box function finish() { select("["+selectObj1.value+"] ["+selectObj2.value+"]") } // ------------ // window.onload=init; //--> </script> I have two dropdown menus. 1st -> Drop Down Menu (name="optionDrop") has 5 values which are "ABC", "ABCD", "ABCDE", "True or False" and "Yes or No". 2nd -> Drop Down Menu (name="numberDrop") has 5 values which are "","1", "2", "3" and "4". Now this is what I want to achieve: If user select "ABC" from "optionDrop", then only display options "", "1" and "2" If user select "ABCD" from "optionDrop", then only display options "", "1", "2" and "3" If user select "ABCDE" from "optionDrop", then only display options "", "1", "2", "3" and "4" If user select "True or False" from "optionDrop", then do not display DropDown Menu and Display N/A (This I achieved but I want hidden numberDrop to equal 1, I have not achieved that part) If user select "Yes or No" from "optionDrop", then do not display DropDown Menu and Display N/A (This I achieved but I want hidden numberDrop to equal 1, I have not achieved that part) Does anyone know how this can be done and implemented in the javascript code I have? Below is Javascript Code: Code: function getDropDown() { var optionDrop = document.getElementsByName("optionDrop"); var na = document.getElementById("na"); var numberDrop = document.getElementsByName("numberDrop"); var answerA = document.getElementById("answerA"); var answerB = document.getElementById("answerB"); var answerC = document.getElementById("answerC"); var answerD = document.getElementById("answerD"); var answerE = document.getElementById("answerE"); var answerTrue = document.getElementById("answerTrue"); var answerFalse = document.getElementById("answerFalse"); var answerYes = document.getElementById("answerYes"); var answerNo = document.getElementById("answerNo"); if (optionDrop[0].value == "abc" || optionDrop[0].value == "abcd" || optionDrop[0].value == "abcde"){ numberDrop[0].style.display = "block"; na.style.display = "none"; }else if (optionDrop[0].value == "trueorfalse" || optionDrop[0].value == "yesorno"){ numberDrop[0].style.display = "none"; na.style.display = "block"; } } Htrml code: Code: <form id="enter" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return validateForm(this);" > <table id="middleDetails" border="1"> <tr> <td>Question:</td> <td rowspan="3"> <textarea rows="5" cols="40" name="questionText"></textarea> </td> <td>Option Type:</td> <td> <select name="optionDrop" onClick="getDropDown()"> <option value="">Please Select</option> <option value="abc">ABC</option> <option value="abcd">ABCD</option> <option value="abcde">ABCDE</option> <option value="trueorfalse">True or False</option> <option value="yesorno">Yes or No</option> </select> </td> <tr> <td colspan="2"></td> <td>Number of Answers:</td> <td> <span id="na">N/A</span> <select name="numberDrop" id="numberDropId" onChange="getButtons()"> <option value=""></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </td> </tr> </table> </form> Tonight is one of those nights - which seem to be coming more often - where I just can't seem to do anything right. Here is the menu I'm using embedded in HTML: Code: <td width="40%" align="center"><font color="#000099"><b> <select id="Aircraft"> <option value="0">N148LH</option> <option value="1">N149LH</option> <option value="2">N150LH</option> <option value="3">N151LH</option> <option value="4">N152LH</option> <option value="5">N153LH</option> <option value="6">N155LH</option> <option value="7">N156LH</option> <option value="8">N157LH</option> <option value="9">N159LH</option> <option value="10">N162LH</option> <option value="11">N163LH</option> </select></b></font></td> Now I want to use that code to trigger default values for my Empty Weights. This is what I have and isn't working: Code: var selectmenu=document.getElementById("Aircraft") if (Aircraft=0) { df.ew.value = 1569.41; df.ew_mom.value = 135909.2; } if (Aircraft=1) { df.ew.value = 1570.11; df.ew_mom.value = 135929.76; } Any help is appreciated. If anyone is interested the page this is on is here. hello I am having a problem to add numbers store in an array. arrayValues[0][0] = 1; arrayValues[0][1] = 2; var col = 0; var sum; for ( var row = 0; row < index; i++ ) sum += arrayValues[col][row]; my result is ==> 12 it is defining my sum variable as string. even I try do do this var sum = 0; to define sum as numeric variable. my result was ==>012. Any idea, this is my first javaScritp code. Thanks. Hi Guys, How do I sum the values of an array and output the result using document.write? Say my array is var number=new Array(1.234,56.43,1.02); THANKS Thought this wud work? Code: <script type="text/javascript"> var x = [1, 2, 3, 4, 5, 6, 7, 8, 9]; document.write(sum(x)); </script> Hi all I am trying to create a code which stores information about songs The information to be stored are : song ID song name song artist song URL So far what I've done is create an empty array with four properties The code asks the user to enter information and then displays them However i'm having difficulty figuring out how to insert all the information entered in the array. For example if information about 3 songs were entered, how can I insert all of them in the array I created. After storing the information, I want to be able to search for songs by their ID. When I wrote the function to do this, if lets say I entered two songs one with S1 as ID and one with S2 as ID, I type S1 in the search box, but it doesn't return anything. However if I enter S2, it returns the information of the track with this ID, which makes me think that entering information for a second song overwrites the first one This is my code so far: <html> <body> <h1>Tracks and Artists</h1> <script type="text/javascript"> function request(tracks) { for (var i=0;i<2;i++) { tracks.trackID = prompt("Enter track ID") tracks.trackName = prompt("Enter track name") tracks.trackArtist = prompt("Enter artist name") tracks.trackURL = prompt("Enter track URL") alert(display(tracks)) } } function insert() { function display(tracks) { return "Track ID: " + tracks.trackID + "\nTrack name: " + tracks.trackName + "\nTrack artist: " + tracks.trackArtist + "\nTrack URL: " + tracks.trackURL } var tracks = [{trackID: "", trackName:"", trackArtist:"", trackURL:"" }] request(tracks) </script> </body> </html> hi, I have this keypressed function: Code: function keyPressed(event, input) { if (event.keyCode == 8) { return true; } var char = event.which ? event.which : event.keyCode; char = String.fromCharCode(char); var exers = "1234 1234 1234"; return (exers.charAt(input.value.length) == char); } This function allow me to press in order the numbers in array (index0). It is works very well. But i want to add an array with more exercises like: Code: var exerc = new Array(); exerc[0]= "1234 1234 1234"; exerc[1] = "5678 5678 5678"; exerc[2] = "9012 9012 9012"; Also, i have a dropdown menu that parser options from a xml file: Code: <form> <select style="width:100px" id='courses'> </select> </form> and my xml file looks like: Code: <courses> <course title="exercise 1"> <lesson>1234 1234 1234</lesson> </course> <course title="exercise 2"> <lesson>5678 5678 5678</lesson> </course> <course title="exercise 3"> <lesson>9012 9012 9012</lesson> </course> . . . </courses> *I write the same index because i have two input field. I see the first choose (depend on dropdown) in first input, and i rewrite the same exercise in the second input. So, it's something like an exercise for me and i stack here. - I repeat. It is work with only one index very well. The problem is that, when i add more that one index in the array. Any suggestion about my problem?Javascript it is not my strong point I try this but it is doesn't work.Baybe it is totally wrong! Code: function keyPressed(event, input) { if (event.keyCode == 8) { return true; } var char = event.which ? event.which : event.keyCode; char = String.fromCharCode(char); var exerc = new Array(); exerc[0]= "1234 1234 1234"; exerc[1] = "5678 5678 5678"; exerc[2] = "9012 9012 9012"; for (i=0;i<exerc.length;i++) { document.getElementById("courses").selectedIndex; } return (exers.charAt(input.value.length) == char); } I'm having problems with selecting values from array. I have a dropdown box where you choose what fruit you want to buy. When selected the array should assign 2 values to that fruit. I don't know how to do that. Here's what I have.. I added comments. Javascript part: Code: <script type="text/javascript"> function Fruits() { var selectfruit = newArray( //assigning values to fruit selected from dropdown box newArray("Banana", 1, 1), newArray("Apple", 1.2, 0.5), newArray("Mango", 1.1, 0.9), newArray("Orange", 0.1, 9.99)); var howmanyfruits = Number(document.getElementById("howmanyfruits").value); // how many fruits are you buying var totalfruitsowned = Number(document.getElementById("totalfruitowned").value); // How many fruits do you already have /* cash and coupons needed to buy fruits. cash is cpst for 1 fruit. coupons is cost for 1 fruit cash_all is cost for all fruits you're buying coupons_all is cost for all fruits you're buying each fruits requires cash AND coupons to be bought. Cash and coupons are tied to the first values in Array. Eg. If you choose Apple that value would be 1.2 The 'fruitsmaxtobuy' variable is not tied to the first value, but the second one in array. If you choose Apple that value would be 0.5. */ var cash = Math.round(((totalfruitsowned * 0.51 * selectfruit) + 700)*10)/10; var coupons = Math.round(((totalfruitsowned * 0.51 * selectfruit) + 850)*10)/10; var cash_all = Math.round((howmanyfruits * cash)*10)/10; var coupons_all = Math.round((howmanyfruits * coupons)*10)/10; var fruitsmaxtobuy = Math.round((totalfruitsowned * 0.12 * selectfruit)*10)/10; /* Display Error if nothing is entered or if you forget to enter total fruits */ if (((howmanyfruits=="" || howmanyfruits==null) && (totalfruitsowned=="" || totalfruitsowned==null)) || ((howmanyfruits==Number(document.getElementById("howmanyfruits").value)) && (totalfruitsowned=="" || totalfruitsowned==null))) {document.getElementById("cash").innerHTML = "Error"; document.getElementById("coupons").innerHTML = "Error"; document.getElementById("cash_all").innerHTML = "Error"; document.getElementById("coupons_all").innerHTML = "Error"; document.getElementById("fruitsmaxtobuy").innerHTML ="Error"} else { document.getElementById("cash").innerHTML = cash; document.getElementById("coupons").innerHTML = coupons; document.getElementById("cash_all").innerHTML = cash_all; document.getElementById("coupons_all").innerHTML = coupons_all; document.getElementById("fruitsmaxtobuy").innerHTML =fruitsmaxtobuy} } </script> HTML part: Code: <form action="" id="fruitcost"> <table align="center" width="37.5%" cellpadding="0" cellspacing="0"> <tbody> <tr> <th colspan="2" align="center">Fruit cost calcultor</th> </tr> <tr> <td>Select Fruit:</td> <td align="center"><select id="selectfruit"> <option>Banana</option> <option selected>Apple</option> <option>Mango</option> <option>Orange</option> </select> </td> </tr> <tr> <td>Total Fruits Owned:</td> <td align="center"><input id="totalfruitsowned" type="text" /></td> </tr> <tr> <td>How many fruits are you buying:</td> <td align="center"><input id="howmanyfruits" type="text" /></td> </tr> <tr> <td>Money Needed to buy 1 fruit:</td><td><font id="cash"></font></td> </tr> <tr> <td>Coupons Needed to buy 1 fruit:</td><td><font id="coupons"></font></td> </tr> <tr> <td>Money Needed:</td><td><font id="cash_all"></font></td> </tr> <tr> <td>Coupons Needed:</td><td><font id="coupons_all"></font></td> </tr> <tr> <td>Nr. of fruits you can buy:</td><td><font id="fruitsmaxtobuy"></font></td> </tr> <tr> <td align="center" colspan="2"><input type="button" value="Submit" onclick="Fruits()" /></td> </tr> </tbody> </table> </form> Hi How can i output two maximum numbers of an array if they are equal? var flower["roses", "violets", "buttercups", "daisies"]; var flowerAmounts[9, 8, 3, 9]; Output should be: The maximum amount of flowers is 9. There are 9 roses and 9 daisies. Hope someone can help, thanks hi, i am currently working on aptana stuidio Nokia WRT to create a mobile widget. the projects requires the retrieval of data from a database. I've created a java servlet in eclipse to connect and execute query to the database. In aptana, i'm using js file and html file. i am able to connect to the servlet, process the data (split it) and store in an array to display the retrieved data on screen. But now i am facing problems to put the retrieved data (array) into a drop down list for selection. can i do it in a js file? thanks =) So I am working on an excercise that the User puts in a Lastname, Firstname, and a score via textboxes. When the user pushes the add student score it should show up in the text area with this format " Brown, John: 92". When looking at the logic, I understand that each text box will need to be different arrays if im right, and then I will have to concat all three arrays into the format and assign it to a variable. Then assign the variable to the value of the text area. I just cannot seem to put the function together or how you would go about it. I just need help with how to go about putting it together. The first code is my body of HTML I'm working with. Code: <body> <div id="content"> <h1>Student Scores</h1> <div id="buddy"> <b>Last Name: </b><input type="text" id="lastName" /> <b>First Name: </b><input type="text" id="firstName" /> <b>Sco </b><input type="text" id="score" /> <input type="button" id="calculate" value="Add Student Scores" /> </div> <fieldset> <legend>Student Scores</legend> <p id="tasks"><textarea id="task_list" rows="20" cols="100"></textarea></p> </fieldset> <div id="yoohoo"> <b>Average sco </b><input type="text" id="averageScore" /> <div> <div id="yes"> <p><input type="button" name="add_task" id="add_task" value="Clear Scores" /></p> <p><input type="button" name="add_task" id="add_task" value="Sort By Last Name" /></p> </div> </body> Hi all, Decided to start learning JavaScript, started 2 days ago. Anyway, I'm trying to create a simple script spits out a styled result based on a user input. Here is my JS: Code: function dispTable (form) { var userCost2 = form.venCost2.value * 1; marArray = new Array ("0.05", "0.1", ".15", "0.2", "0.25", "0.3", "0.35", "0.4", "0.45", "0.5", "0.55", "0.6", "0.65", "0.7", "0.75", "0.8"); for (var i=0; i<marArray.length; i++) { document.tableDiv.innerHTML = "<div>" document.tableDiv.innerHTML = userCost2; document.tableDiv.innerHTML = marArray[i]; document.tableDiv.innerHTML = + userCost2 * marArray[i]; document.tableDiv.innerHTML = "<\/div>"; } } Here is my HTML: Code: <div class="container"> <form name="lasoCalcTable"> <span>Enter Vendor Cost</span> <input class="textForm" name="venCost2" id="venCost2" type="text" size="8" /> <hr /> <input class="butForm" name="calcTblBut" type="button" value="Calculate" onclick="dispTable()" /><br /> </form> <div title="tableDiv" id="tableDiv"> </div> </div> The problem is that nothing is happening when I press the calculation button. What I would like to happen is to display a div element for each value in the array which displays the entered value from VenCost2, the current Margin %, and the result of VenCost2 * margin%. I want this to display on the same page and underneath the calculation button, preferably not having to reload the page. I thought this was going to be relatively easy but doesn't seem so! Thanks for your help |