JavaScript - Creating Html Link Using Variable
I'm using a form data reference, something like P-1234 for example to create a text file and a link to the file. This is during the construction of a new table or table row with javascript. I have an array of one or more references submitted via form using $_POST. On my action page I am creating a txt file P-1234. If I am creating a table ot table row using createElement(), one of the cells will have a link to the file.
If the file is created as follows: PHP Code: $File = $_POST['ref'][$i] . "txt"; After creating the cell Code: var Cell = document.createElement('td'); I assign the file to a variable var File = "<?= $File ?> "; I assume the link is inserted using innerHTML? If so, do I just append the filename to the end of the file path like this? Cell.innerHTML = "http://localhost/Project/+File"; If this is not the right way can someone point me in the right direction? Similar TutorialsI would like to apologize in advance if my question sounds too simple. I am a novice to Javascript and have not had any real formal training here. I am creating a webpage which utilizes a separate .xml file to populate values in my webpage. This is my webpage (links.html): and here is my xml file (links_data.xml): This is my output: I have a link at the bottom of the page that points to the device being displayed. In this case, the link should be: http://10.90.139.201 If my xml file changes, it should point to the new IP address. My question is, how do I get the link to work? Currently, my current link (<a href="http://"IP_address"">Link</a>) does not populate any information. Appreciate any guidance here... thanks. Is it possible to make it so if you click on a <a href> the information such as the name or link changes the <title> of the page and replaces existing opened <div>s with information from the link or such. eg If i had a list of swf files that were attatched to links how could I display each swf file onclick without redirecting whilst changing the title and content? I am working on a javascript for my blackberry. I am trying to capture the latitude and longitude of that phone. I am able to get the coordinates in an alert box but am having a little trouble writing it to a form input field. Can anyone help me with this? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>GPS Testing</title> </head> <body> <script type="text/javascript"> if(blackberry.location.GPSSupported){ document.write("Your device supports GPS locating"); blackberry.location.onLocationUpdate(window.alert("Latitude: " + blackberry.location.latitude + " Longitude: " + blackberry.location.longitude)); var lat = blackberry.location.latitude(); var lng = blackberry.location.longitude(); blackberry.location.refreshLocation(); document.write(lat); } </script> </body> </html> I am only able to test with Blackberry. I was trying to create a couple of variables with the "var lat =" and var lng =". With this script I get the alert window and when I click ok it writes "Your device supports ..." Thanks for any help! Hello everyone, I'm new to the programming world so please be kind I'm trying to find a code which would take the input value entered in a form field and on click direct you to a page which corresponds with what was entered. So for example: Enter "5" in field. Click Submit. Page opens up (which in fact would be an html file on my server called... 5.html) ( i would want to create 10 pages for values entered from 1-10... each value having a unique result when entered and clicked) I have no idea how to put this all together, i've been searching everywhere. Any kind of help would be appreciated. Code: var x = "blahblah".indexOf("blahblah"); if (x !== -1){ // do something with x alert("Present"); } else { alert("Not present"); } Is there some syntax/code structure that allows something like this: Code: if ( (var x = "blahblah".indexOf("blahblah")) !== -1){ // do something with x alert("Present"); } else { alert("Not present"); } Is this possible? Code: String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, ""); } var myStr = " Hi what's up? "; myStr.trim(); alert("{" + myStr + "}"); //will result in the original string, not the trimmed version It's possible with numbers: Code: var myNum = 10; myNum++; alert(myNum); //11 Hello, I'm trying to create a webpage where users can click on a dynamically generated set of questions: <?php do { ?> <p><?php echo $row_rsQuestions['question_text']; ?><?php echo $row_rsQuestions['question_type']; ?></p> <?php } while ($row_rsQuestions = mysql_fetch_assoc($rsQuestions)); ?> and by clicking on a particular question, there will be an update for their particular listing of personal questions in a MySql database. I know how to create the database update part, but I think that I would need to javascript to: 1) tell my page that it's time to update (i.e. add a particular question as soon as they click it) 2) pass along the correct variable to the database update portion of the page. Any help on these two items would be appreciated. Thank you! Very new to javascript, so I apologize in advance. I honestly tried to figure this out on my own, and I'm just not able. I'm trying to create a family tree online that has several other related family charts. I want each person's name and birth year to be stored in javascript variables, then I want to be able to just go through the tree, and put the persons name once, and have it put the appropriate name and birthyear in the little boxes that the css is creating. In the js file... I would do this for each family member. Code: var johnname = "John Smith"; var johnbirthyear = "Jan 1 1930"; var janename = "Jane Doe"; var janebirthyear = "Jan 1 1940"; var mikename = "mike wilson"; var mikebirthyear = "Jan 1 1950"; var saraname = "sara johnston"; var sarabirthyear = "Jan 1 1960"; In the HTML file... Code: <div id = "boybox"> <script type="text/javascript"> id = "john"; <!-- this is the only thing I want to have to change --> name = id+"name"; document.write(name); </script> <div id = "year"> <script type="text/javascript"> birthyear = id+"year"; document.write(birthyear); </script> </div> </div> So I thought I had it all figured out. I thought that the above would take the id of John that I added, go to the line that sets the name, add john to the word name, and then document write the variable of johnname from the js file. I know you're laughing at me because of course it instead made the value of name to johnname, then wrote the word johnname in the box. Can anyone point me in the right direction please? ultimately I want to go through and be able to just type the persons name in the html for that box once, and have it update with their appropriate info. Thanks, and sorry for such a rookie question. Hi all, I think I have posted in the right place, if not appologies. Anyhow, I am currently creating a website for my canvas printing business and run into a few javascripting issues. I am trying to create a small navigation form whereby a customer can select from a dropdown the required width of canvas, this selection will then populate a second dropdown with a choice of canvas heights. Ok, so trawling many sites I came across some javascript that I was able to chop about and have this part sorted. The problem now is that I would like to include a submit button that when clicked takes the customer to a webpage based on their two dropdown choices, and being a complete newby when it comes to javascript I am stuck trying to include the script to enable this. eg: if they select '20" (51cm)' from the first dropdown and '16" (41cm)' from the second dropdown, they will navigate to "http: / / 20x16.co.uk" canvas print page. I have not currently created the canvas print pages so am unable to give the URLs of the pages. However if somebody can lend a hand to get me started and indicate where the desitnation URLs need to be added, I can drop these in later. The way that the script is currently written, the linked url could be based soley on the choice made in the second dropdown. I have a draft page with the working dropdowns he http://merchant.auctivacommerce.com/...iewtheme=32189 And the code that I currently have is: Code: <script type="text/javascript"> var SELECT_WIDTH_FIRST = []; var WIDTH08 = []; var WIDTH10 = []; var WIDTH12 = []; var WIDTH14 = []; var WIDTH16 = []; var WIDTH18 = []; var WIDTH20 = []; var WIDTH24 = []; var WIDTH30 = []; var WIDTH36 = []; var WIDTH42 = []; var WIDTH48 = []; var WIDTH60 = []; var WIDTH72 = []; SELECT_WIDTH_FIRST[0] = new Option("Please Select Width First", "SelWidFir"); WIDTH08[0] = new Option("8'' (20cm)", "0808"); WIDTH08[1] = new Option("10'' (25cm)", "0810"); WIDTH08[2] = new Option("12'' (30cm)", "0812"); WIDTH08[3] = new Option("14'' (35cm)", "0814"); WIDTH08[4] = new Option("16'' (41cm)", "8016"); WIDTH08[5] = new Option("18'' (46cm)", "0818"); WIDTH08[6] = new Option("20'' (51cm)", "0820"); WIDTH08[7] = new Option("24'' (61cm)", "0824"); WIDTH10[0] = new Option("8'' (20cm)", "1008"); WIDTH10[1] = new Option("10'' (25cm)", "1010"); WIDTH10[2] = new Option("12'' (30cm)", "1012"); WIDTH10[3] = new Option("14'' (35cm)", "1014"); WIDTH10[4] = new Option("16'' (41cm)", "1016"); WIDTH10[5] = new Option("18'' (45cm)", "1018"); WIDTH10[6] = new Option("20'' (51cm)", "1020"); WIDTH10[7] = new Option("24'' (61cm)", "1024"); WIDTH10[8] = new Option("30'' (76cm)", "1030"); WIDTH12[0] = new Option("8'' (20cm)", "1208"); WIDTH12[1] = new Option("10'' (25cm)", "1210"); WIDTH12[2] = new Option("12'' (30cm)", "1212"); WIDTH12[3] = new Option("14'' (35cm)", "1214"); WIDTH12[4] = new Option("16'' (41cm)", "1216"); WIDTH12[5] = new Option("18'' (45cm)", "1218"); WIDTH12[6] = new Option("20'' (51cm)", "1220"); WIDTH12[7] = new Option("24'' (61cm)", "1224"); WIDTH12[8] = new Option("30'' (76cm)", "1230"); WIDTH12[9] = new Option("36'' (91cm)", "1236"); WIDTH14[0] = new Option("8'' (20cm)", "1408"); WIDTH14[1] = new Option("10'' (25cm)", "1410"); WIDTH14[2] = new Option("12'' (30cm)", "1412"); WIDTH14[3] = new Option("14'' (35cm)", "1414"); WIDTH14[4] = new Option("16'' (41cm)", "1416"); WIDTH14[5] = new Option("18'' (45cm)", "1418"); WIDTH14[6] = new Option("20'' (51cm)", "1420"); WIDTH14[7] = new Option("24'' (61cm)", "1424"); WIDTH14[8] = new Option("30'' (76cm)", "1430"); WIDTH14[9] = new Option("36'' (91cm)", "1436"); WIDTH14[10] = new Option("42'' (107cm)", "1442"); WIDTH16[0] = new Option("8'' (20cm)", "1608"); WIDTH16[1] = new Option("10'' (25cm)", "1610"); WIDTH16[2] = new Option("12'' (30cm)", "1612"); WIDTH16[3] = new Option("14'' (35cm)", "1614"); WIDTH16[4] = new Option("16'' (41cm)", "1616"); WIDTH16[5] = new Option("18'' (45cm)", "1618"); WIDTH16[6] = new Option("20'' (51cm)", "1620"); WIDTH16[7] = new Option("24'' (61cm)", "1624"); WIDTH16[8] = new Option("30'' (76cm)", "1630"); WIDTH16[9] = new Option("36'' (91cm)", "1636"); WIDTH16[10] = new Option("42'' (107cm)", "1642"); WIDTH16[11] = new Option("48'' (122cm)", "1648"); WIDTH18[0] = new Option("8'' (20cm)", "1808"); WIDTH18[1] = new Option("10'' (25cm)", "1810"); WIDTH18[2] = new Option("12'' (30cm)", "1812"); WIDTH18[3] = new Option("14'' (35cm)", "1814"); WIDTH18[4] = new Option("16'' (41cm)", "1816"); WIDTH18[5] = new Option("18'' (45cm)", "1818"); WIDTH18[6] = new Option("20'' (51cm)", "1820"); WIDTH18[7] = new Option("24'' (61cm)", "1824"); WIDTH18[8] = new Option("30'' (76cm)", "1830"); WIDTH18[9] = new Option("36'' (91cm)", "1836"); WIDTH18[10] = new Option("42'' (107cm)", "1842"); WIDTH18[11] = new Option("48'' (122cm)", "1848"); WIDTH18[12] = new Option("60'' (152cm)", "1860"); WIDTH18[13] = new Option("72'' (183cm)", "1872"); WIDTH20[0] = new Option("8'' (20cm)", "2008"); WIDTH20[1] = new Option("10'' (25cm)", "2010"); WIDTH20[2] = new Option("12'' (30cm)", "2012"); WIDTH20[3] = new Option("14'' (35cm)", "2014"); WIDTH20[4] = new Option("16'' (41cm)", "2016"); WIDTH20[5] = new Option("18'' (45cm)", "2018"); WIDTH20[6] = new Option("20'' (51cm)", "2020"); WIDTH20[7] = new Option("24'' (61cm)", "2024"); WIDTH20[8] = new Option("30'' (76cm)", "2030"); WIDTH20[9] = new Option("36'' (91cm)", "2036"); WIDTH20[10] = new Option("42'' (107cm)", "2042"); WIDTH20[11] = new Option("48'' (122cm)", "2048"); WIDTH20[12] = new Option("60'' (152cm)", "2060"); WIDTH20[13] = new Option("72'' (183cm)", "2072"); WIDTH24[0] = new Option("8'' (20cm)", "2408"); WIDTH24[1] = new Option("10'' (25cm)", "2410"); WIDTH24[2] = new Option("12'' (30cm)", "2412"); WIDTH24[3] = new Option("14'' (35cm)", "2414"); WIDTH24[4] = new Option("16'' (41cm)", "2416"); WIDTH24[5] = new Option("18'' (45cm)", "2418"); WIDTH24[6] = new Option("20'' (51cm)", "2420"); WIDTH30[0] = new Option("10'' (25cm)", "3010"); WIDTH30[1] = new Option("12'' (30cm)", "3012"); WIDTH30[2] = new Option("14'' (35cm)", "3014"); WIDTH30[3] = new Option("16'' (41cm)", "3016"); WIDTH30[4] = new Option("18'' (45cm)", "3018"); WIDTH30[5] = new Option("20'' (51cm)", "3020"); WIDTH36[0] = new Option("12'' (30cm)", "3612"); WIDTH36[1] = new Option("14'' (35cm)", "3614"); WIDTH36[2] = new Option("16'' (41cm)", "3616"); WIDTH36[3] = new Option("18'' (45cm)", "3618"); WIDTH36[4] = new Option("20'' (51cm)", "3620"); WIDTH42[0] = new Option("14'' (35cm)", "3614"); WIDTH42[1] = new Option("16'' (41cm)", "3616"); WIDTH42[2] = new Option("18'' (45cm)", "3618"); WIDTH42[3] = new Option("20'' (51cm)", "3620"); WIDTH48[0] = new Option("16'' (41cm)", "4816"); WIDTH48[1] = new Option("18'' (45cm)", "4818"); WIDTH48[2] = new Option("20'' (51cm)", "4820"); WIDTH60[0] = new Option("18'' (45cm)", "6018"); WIDTH60[1] = new Option("20'' (51cm)", "6020"); WIDTH72[0] = new Option("18'' (45cm)", "7218"); WIDTH72[1] = new Option("20'' (51cm)", "7220"); function populateSub(mainSel, subSel){ var mainMenu = mainSel; var subMenu = subSel; var subMenuItems; subMenu.options.length = 1; switch (mainMenu.selectedIndex) { case 0: subMenuItems = SELECT_WIDTH_FIRST; break; case 1: subMenuItems = WIDTH08; break; case 2: subMenuItems = WIDTH10; break; case 3: subMenuItems = WIDTH12; break; case 4: subMenuItems = WIDTH14; break; case 5: subMenuItems = WIDTH16; break; case 6: subMenuItems = WIDTH18; break; case 7: subMenuItems = WIDTH20; break; case 8: subMenuItems = WIDTH24; break; case 9: subMenuItems = WIDTH30; break; case 10: subMenuItems = WIDTH36; break; case 11: subMenuItems = WIDTH42; break; case 12: subMenuItems = WIDTH48; break; case 13: subMenuItems = WIDTH60; break; case 14: subMenuItems = WIDTH72; break; } for (var i = 0; i < subMenuItems.length; i++) { subMenu.options[i] = subMenuItems[i]; } } </script> <div style="width:320px; text-align:right;"> <form name="Menus"> <label style="font-size:14px; font-variant:small-caps;">Width</label> <select style="width:250px; margin-bottom:10px;" name="Width" onchange="populateSub(this, this.form.Height);"> <option>Please Select</option> <option value="W08">8'' (20cm)</option> <option value="W10">10'' (25cm)</option> <option value="W12">12'' (30cm)</option> <option value="W14">14'' (35cm)</option> <option value="W16">16'' (41cm)</option> <option value="W18">18'' (46cm)</option> <option value="W20">20'' (51cm)</option> <option value="W24">24'' (61cm)</option> <option value="W30">30'' (61cm)</option> <option value="W36">36'' (61cm)</option> <option value="W42">42'' (61cm)</option> <option value="W48">48'' (61cm)</option> <option value="W60">60'' (61cm)</option> <option value="W72">72'' (61cm)</option> </select> <label style="font-size:14px; font-variant:small-caps;">Height</label> <select style="width:250px; margin-bottom:10px;" name="Height"> <option>Please Select Width First</option> </select> <input type="button" value="View Canvas!"> </form> </div> As mentioned, Javascript is completely new to me but I am attempting to learn. Any help would be greatly appreciated. Wayne Hi, I'm really new to Javascript. Recently in my IT class, we made a HTML page which would open a popup box, where the user could enter a key word. When the user pressed enter, the page would navigate to a specific page. The code we used was: Code: <script language = "JavaScript"> where = window.prompt ("Please tell me where you would like to go."); switch (where){ case "Digg" : window.location = "http://www.digg.com" ; break; default: window.location = "http://www.google.com" ; } </script> What I am hopeing to do, is implement this code on my workplaces server, and have the keywords link to other html documents within the server. However when I tested this, for some reason the links are not working. Can this actually be done? Am I missing something silly? Are there any other ways of doing this? Thanks in advance Hi, I have a simple page and a javascript that measure the time the user has spent on a page and I want that variable to pass as a link to another page (php). I'm stuck (rookie) with how to actually pass that on in the link. Here's my code: Code: <?php session_start();?> <html> <head> <script type="text/javascript"> /* This script and many more are available free online at The JavaScript Source :: http://javascript.internet.com Created by: Cody Shaffer :: http://codytheking313.byethost11.com */ var time=1; function timeHere() { time = time + 1; finalTime = time / 10; } </script> </head> <body> <div id="container"> <form id="form1" method="post" action=""> <label>Fill this Data <input type="text" name="1" id="1" /> </label> <p> <label> <input type="submit" name="2" id="2" value="Submit" /> </label> </p> </form> <a href="go/index.html">ads</a> </div> </body> </html> Thanks for the help Hi, I wanna make a form that receives: textbox URL And textbox Anchor and result will be two anchors one <a href, and one phpBB Example: Url: www.pushpin.co.il Anchor: pushpin Results: <a href="http://www.pushpin.co.il">pushpin</a> [ url = http://www.pushpin.co.il/ ] pushpin[ /url ] Help? I am trying to remove all Javascript code from my HTML doc and put into external .js file(s). I have event triggers that I would like to move to an external file, but I am not sure how. Below is an example. [CODE] <a href="residential.html" class="textdeco" > <img class="img-menu" id="res" src="images/buttons/btn_res_mouse_out.jpg" alt="Residential" onmouseover="FP_swapImg(1,0,/*id*/'res',/*url*/'images/buttons/btn_res_mouse_over.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'res',/*url*/'images/buttons/btn_res_mouse_out.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'res',/*url*/'images/buttons/btn_res_mouse_down.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'res',/*url*/'images/buttons/btn_res_mouse_up.jpg')" /> [CODE] The reason I want to do this is that this code is repeated in all pages and I want to reduce potential maintenance issues. Any help will be appreciated. Evening all. Here's a snippet: Code: canvases[i] = document.createElement('canvas'); canvases[i].style.width = '3px'; canvases[i].style.height = '100%'; canvases[i].getContext("2D"); canvases[i].fillRect(1,0,1,table_height); I'm trying to dynamically create a canvas element. Later in the script it gets attached to the DOM, and this works fine if the last two lines are missing. I end up with a canvas element that is 3px wide and 100% of the containing div tall. However, the last two lines make it crash, with the error report 'canvases[i].fillRect is not a function'. If I change the last two lines to Code: var drawing = canvases[i].getContext("2D"); drawing.fillRect(1,0,1,table_height); it says 'drawing is null'. Something seems to be going wrong with the getContext bit, because setting the height and width work fine. Any ideas? It behaves the same if I append the canvas element to the DOM before trying to do the drawing as well. This is in FF4.0.1 with a xhtml1-strict.dtd doctype and valid html. Thanks, Chris Hi im wondering if someone could be of some help please, im a newbie to javascript and after some help and advice if possible please. Ive used a template from the web which was a quiz template. Im just trying to get my javascript script to work. I want it to populate my html question/advice box so people can input what there answer to the question and it will give them advice. It's for a data classification advice for a work project. I just dont know where im going wrong or what im missing out - ive read loads of help sections on the web and still cant get the javascript to populate my html boxes. Any help or advice would be really appreciated. Thanks Lee Heres my html code which seems to work ok... the box etc is displayed just doesnt have any content. ----------------------------------------------------------------------- Code: <form method="POST"> <div align="center"><center><table BORDER="1"> <tr> <td COLSPAN="2" BGCOLOR="#4C0000"><div align="center"><center><p><font SIZE="+3" COLOR="#FFFFFF">Data Classification </font></td> </tr> <tr> <td COLSPAN="2" BGCOLOR="#4C0000"><div align="center"><center><p><font SIZE="-1" COLOR="#FFFFFF">2010 <a HREF="Data Governance</font> </p> </center></div><div align="center"><center><p><font COLOR="#FFFFFF">Click on "Next Question" to start advice. Be sure to use small letters (no caps) when entering your letter choice.</font> </td> </tr> <tr> <td><b>Question #:</b></td> <td ALIGN="LEFT"><input TYPE="TEXT" NAME="questNo" SIZE="4"></td> </tr> <tr> <td><b>Question:</b></td> <td><div align="center"><center><p><textarea COLS="70" ROWS="2" name="question" wrap="virtual"></textarea></td> </tr> <tr> <td ALIGN="RIGHT"><b>a)</b></td> <td><div align="center"><center><p><input TYPE="TEXT" NAME="choiceA" SIZE="75"></td> </tr> <tr> <td ALIGN="RIGHT"><b>b)</b></td> <td><div align="center"><center><p><input TYPE="TEXT" NAME="choiceB" SIZE="75"></td> </tr> <tr> <td ALIGN="RIGHT"><b>c)</b></td> <td><div align="center"><center><p><input TYPE="TEXT" NAME="choiceC" SIZE="75"></td> </tr> <tr> <td ALIGN="RIGHT"><b>d)</b></td> <td><div align="center"><center><p><input TYPE="TEXT" NAME="choiceD" SIZE="75"></td> </tr> <tr> <td ALIGN="RIGHT"><b>Your choice:</b></td> <td><input TYPE="TEXT" NAME="yourChoice" SIZE="4"></td> </tr> <tr> <td COLSPAN="2"><div align="center"><center><p><input TYPE="button" VALUE="Check Current Advice" onClick="checkAnswer(this.form)"><input TYPE="button" VALUE="Next Question" onClick="nextQuestion(this.form)"> <input TYPE="reset" VALUE="Start Over" onClick="clearForm(this.form)"></td> </tr> <tr> <td ALIGN="RIGHT"><b>Results:</b></td> <td><div align="center"><center><p><textarea COLS="70" ROWS="3" name="Advice" wrap="virtual"></textarea></td> </tr> <tr> </form> -------------------------------------------------------------------------- Now heres my javascript which i just cant seem to get to work or integrate with the html question/advice box. There will be some text in there that was originally part of the template that i was going to remove at a later stage once id got a better underatnding of where i was going wrong. Code: <html> <head> <script LANGUAGE="JavaScript"> <!-- hide this script tag's contents from old browsers ---> function jumpBox(list) { location.href = list.options[list.selectedIndex].value } //Lee Quinn 2010 All Rights Reserved function init() { questions = new Array() questions[1] = "Is the information you are collecting or creating any of the following?" questions[2] = "Is the information you are collecting or creating any of the following?" questions[3] = "Is the information you are collecting or creating any of the following?" questions[4] = "Is the information you are collecting or creating any of the following?" answerA = new Array() answerA[1] = "Marketing brochures, Customer disclosure statements,Published annual reports, Interviews with news media, Press releases" answerA[2] = "Employee Handbook,Telephone Directory,Organization Charts,Policies and Standards,Training Manuals" answerA[3] = "Customer records, Correspondence containing customer information, Credit card listings,Personnel records/Employee performance reviews,Unit business plans,Proprietary/custom software,Budget information,Internal audit reports,Business reports on strategy, exposures etc" answerA[4] = "Strategic Plans,Encryption keys,Details of mergers or acquisitions,Financial results prior to publication,Online access codes such as passwords or pin" answerB = new Array() answerB[1] = "None of the above" answerB[2] = "None of the above" answerB[3] = "None of the above" answerB[4] = "None of the above" rightAns = new Array rightAns[1] = "A" rightAns[2] = "b" rightAns[3] = "c" rightAns[4] = "d" reference = new Array() reference[1] = "You have indicated yes to question 1, therefore the information you are collecting/creating will be classified as PUBLIC information. It is information that can be disclosed to anyone without violating an individual?s right to privacy. Knowledge of this information does not expose CFS to financial loss, embarrassment, or jeopardize the security of assets." reference[2] = "You have indicated yes to question 2, therefore the information you are collecting/creating will be classified as INTERNAL USE information. It is information that, due to technical or business sensitivity, is limited to employees and contractors who work on-site. It is intended for use only within CFS. Unauthorized disclosure, compromise, or destruction would not have a significant impact on CFS or its employees." reference[3] = "You have indicated yes to question 3, therefore the information you are collecting/creating will be classified as CONFIDENTIAL information. It is information that CFS and its employees have a legal, regulatory, or social obligation to protect. It is intended for use solely within defined groups in CFS. Unauthorized disclosure, compromise, or destruction would adversely impact CFS its customers or its employees. Unless otherwise stated all data should be treated as CONFIDENTIAL.Sensitive data = Confidential or Highly Confidential data." reference[4] = "You have indicated yes to question 4, therefore the information you are collecting/creating will be classified as HIGHLY CONFIDENTIAL information, It is the highest level of classification and is information whose unauthorized disclosure, compromise, or destruction could result in severe damage, provide significant advantage to a competitor, or incur serious financial impact to CFS or its employees. It is intended for restricted use by a very small number of people (possibly 0 or 1) with an explicit, predetermined need to know." } function nextQuestion(form) //set the total number of questions equal to quizend { var quizEnd = eval(4 * 1); if(form.questNo.value =5= quizEnd) { form.question.value = "1"; form.choiceA.value = "Marketing brochures, Customer disclosure statements,Published annual reports, Interviews with news media, Press releases"; form.choiceB.value = "None of the above"; form.choiceC.value = "Unsure"; form.yourChoice.value = "a,b,c,d"; form.results.value = "End of Advice. Your final results are listed below."; } else { if(form.questNo.value == "") {form.questNo.value = 1} else { form.questNo.value = eval(form.questNo.value) + 1; } form.question.value = questions[form.questNo.value]; form.choiceA.value = answerA[form.questNo.value]; form.choiceB.value = answerB[form.questNo.value]; form.choiceC.value = answerC[form.questNo.value]; form.choiceD.value = answerD[form.questNo.value]; form.yourChoice.value = ""; form.results.value = ""; if(form.myScore.value == "") {form.myScore.value = 0; } else { form.myScore.value = form.myScore.value; } } } function checkcurrentadvice(form) { var myScore = 0; var curve = 0; if(form.results.value != "") {form.results.value = "Sorry, no guessing allowed. In order to retry this question you will have to start the quiz over. Click on ''Next Question'' to continue."; } else if(form.yourChoice.value == rightAns[form.questNo.value]) { form.myScore.value = eval(form.myScore.value) + eval(1); form.results.value = "Conratulations! You are correct. That brings your cumulative score to " + form.myScore.value + " out of a possible " + form.questNo.value + ". Click on ''Next Question'' to continue."; } else { form.results.value = "Sorry, you are incorrect. Please refer to " + reference[form.questNo.value] + " before retaking the quiz. This brings your cumulative score to " + form.myScore.value + " out of a possible " + form.questNo.value + ". Click on ''Next Question'' to continue." } function clearForm(form) { form.questNo.value = ""; form.question.value = ""; form.choiceA.value = ""; form.choiceB.value = ""; form.choiceC.value = ""; form.choiceD.value = ""; form.yourChoice.value = ""; form.results.value = ""; form.myScore.value = ""; form.percent.value = ""; form.grade.value = ""; } </script> </head> </html> I am trying to create a simple HTML table with the squares of numbers and for some reason the loop is not triggering. Code: Code: <table border="1"> <tr><td><h2>Table of Squares</h2></td></tr> <tr><td> Number </td> <td> Square </td></tr> <tr> <script language="JavaScript"> for(i = 1, fact = 1; i < 10; i++, fact = i*i) { document.write("<td>" + i + " </td><td> " + fact + "</td>); document.write("</tr><tr>"); } document.write("</tr></table>"); </script> When I run the page all that comes up is the start of the table that is written before the script executes. Also is there any way I could use a debugger to catch this on my own? I tried the firefox debugger but it didn't catch anything when I ran it through, maybe I was just doing it wrong. Any help is appreciated thanks! Hi, I am creating a HTML page and mailing it to the user(client side). This html page contains a Table and a button. On button click, I would like to create another HTML page based on the detail in the table,dynamically on run time and Open the newly created HTML. I need to use javascript to achieve this functionality. I have no Server-Client Configuration. And I need to run the Javscript only on client side to process the First HTML's table data and Create a new HTML page. The output of the javascript should also be put in a table format in the newly created HTML page. Here is some background information: The details from one server would be put into this first HTML along with a button. This HTML page is then mailed to Client side. The javascript in the HTML page then processes the Table data of first HTML. This can only be run at Client Side,once the user clicks the button and moreover I dont have Server-Client Configuration. I am creating a report and mailing it, For formatting purposes and for creating hyperlink to mailid's I chose HTML, Now I am struck here. Could some one please help me out with this. Thanks for your time. hi i have a hidden variable in html like this <input type="hidden" name="searchword" value=""> and i need to change the value using javascript. You can do it in vbscript with searchword.value="test" but i dont know how to in javascript ive tried document.searchword.value=cookie_text; cookie_text is a variable by the way thanks Hi I want to use the javascript variable value in html , for example <script > var alignment = "Right"; </script> <html> <p align = alignment > Hi </p> </html> How can i do like this ! I have two versions of this document. The first version uses only JavaScript and the standard PROMPT(). It works very well, but I would like to insert the name prompt into the page using the input command. For some reason the variable loaded in the HTML statement doesn't get passed to the JavaScript. Any ideas would be appreciated! This is only a small test page. Sorry I don't know about the [code] tag... <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)"> <meta name="created" content="Sat, 10 Sep 2011 19:40:31 GMT"> <meta name="description" content=""> <meta name="keywords" content=""> <title>Enter golfers name</title> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <SCRIPT LANGUAGE="JavaScript" type="text/javascript" src="script1.js"></SCRIPT> <SCRIPT LANGUAGE="JavaScript"> function GetPage(){ document.write("OK") var lab = ""; var result = fullname.toUpperCase(); var word=result.split(" "); fname = word[0] lname = word[1] alpha = lname.slice(0,1); lab = fname.concat("_") lab = lab.concat(lname) if(word[2]){ ext = word[2] lab = lab.concat("_") lab = lab.concat(ext) } var intro = "./Stats_"; page = intro.concat(alpha); page = page.concat("_golfers.html#"); page = page.concat(lab) document.write(page) <!-- window.location.pathname = page } </script> </head> <body> <center> <form action="form_action.asp" method="get"> You can enter the golfersname or select him from the above list.<br><br> <input type="text" name="fullname" /> <button type="submit" onclick="GetPage()">GO</button> </form> </center> <BR><BR><BR> This is the end </body> </html> |