JavaScript - Javascript Phrases Based On Outputted Scores?
How do I get the following phrases to output along with their corresponding scores for my algorithm below?
Here are the phrases I'd like to see along side the outputted score Scores: 90-100 --- Legendary</td></tr> 80-90 --- All-Star Performance 70-80 --- D1 College Level 60-70 --- Very Good 50-60 --- Great Effort 40-50 --- Almost there! 30-40 --- Nice try 20-30 --- Try harder 10-20< --- Don't give up. 0-10 --- A ways to go... Below 0 --- Poor Performance Above 100 --- Yeah Right! And here's my formula that asks for 4 values then spits out a number. Code: <br> <center><img src="http://i40.photobucket.com/albums/e250/jonsan32/easy.png"></center> <br><script language="javascript"> function addNumbers() { var val1 = parseInt(document.getElementById("value1").value); var val2 = parseInt(document.getElementById("value2").value); var val3 = parseInt(document.getElementById("value3").value); var val4 = parseInt(document.getElementById("value4").value); var ansD = document.getElementById("answer"); ansD.value = Math.round(((100-(25-val1)*5)/4 + (100-6.66667*(23-val2))/4 + (100-7.51*(15-val3))/4 + (100-4*(32-(val4)))/4)*100)/100 ; } </SCRIPT> <table width=700><tr><td>XDrill = <input type="text" id="value1" name="value1" value="" SIZE=2 /> <br><br></td><td> 2ptrs = <input type="text" id="value2" name="value2" value="" SIZE=2/><br><br> </td><td> 3ptrs = <input type="text" id="value3" name="value3" value="" SIZE=2/><br><br> </td><td> Nash = <input type="text" id="value4" name="value4" value="" SIZE=2/><br><br></td><td> <input type="button" name="Submit" value="Click here" onclick="javascript:addNumbers()"/><br><br> </td></tr><tr><td colspan=2 bgcolor="#000000"><center> <font color="#ffffff">Your Score = <input type="text" id="answer" name="answer" value=""/ SIZE=4> </center></td></tr></table> <br><br> Similar TutorialsHi, I want to make a simple quiz in HTML using JavaScript. I have made a web page called scoreboard which contains two tables. I have attached the screen shot of how the web page looks as well as the coding here with this msg. below is the description of my web page. If you find it lengthy or not understandable, pls refer my attached image of the web page. Description one table contains two rows - one for direct answers and another for answers which are given during their pass chance in the quiz. There are four buttons - Team A, Team B, Team C and Team D for both the direct and pass. And the second table contains four text boxes which which displays the score for each Team. Now, in my web page i have typed the required coding so that when in click the TeamA, TeamB,...buttons in the direct row, the score board for Team A adds up 10 points. Now i want to add 5 points for the respective teams when i click their team button in the pass row. I am not able to code that. I am new to JS. so pls help me. the code goes below. thanks in advance. Code: <html> <head> <title>score card</title> <form name="myform"> <script language="javascript"> function score_computeA(n) { var score = parseInt(document.myform.t1.value,10); n = parseInt(n,10); score= score + n; document.myform.t1.value = score; } function score_computeB(n) { var score = parseInt(document.myform.t2.value,10); n = parseInt(n,10); score= score + n; document.myform.t2.value = score; } function score_computeC(n) { var score = parseInt(document.myform.t3.value,10); n = parseInt(n,10); score= score + n; document.myform.t3.value = score; } function score_computeD(n) { var score = parseInt(document.myform.t4.value,10); n = parseInt(n,10); score= score + n; document.myform.t4.value = score; } </script> </head> <body> <p align="center"><font face="Broadway" size="6">School name goes here</font></p> <p align="center"><font face="Baskerville Old Face" color="#FF0000" size="5"> Quiz</font></p> <p align="center"> </p> <p align="center"><font face="Arial Rounded MT Bold" size="5" color="#008000"> Administrative Panel</font></p> <div align="center"> <table border="1" width="69%" height="83"> <tr> <td width="98" height="35"> <p align="left">Direct</td> <td height="35"> <p align="center"><input type="button" value="Team A" name="d1" onclick = "score_computeA(10)"></td> <td height="35"> <p align="center"><input type="button" value="Team B" name="d2" onclick = "score_computeB(10)"></td> <td height="35"> <p align="center"><input type="button" value="Team C" name="d3" onclick = "score_computeC(10)"></td> <td height="35"> <p align="center"><input type="button" value="Team D" name="d4" onclick = "score_computeD(10)"></td> </tr> <tr> <td width="98">Pass</td> <td> <p align="center"><input type="button" value="Team A" name="p1" onclick ="pass_computeA(5)"></td> <td> <p align="center"><input type="button" value="Team B" name="p2"></td> <td> <p align="center"><input type="button" value="Team C" name="p3"></td> <td> <p align="center"><input type="button" value="Team D" name="p4"></td> </tr> </table> <hr> <p align="center"> <font face="Arial Rounded MT Bold" size="5" color="#008000">Score Card</font></p> <table border="1" width="59%" height="82"> <tr> <td width="155">Team</td> <td width="177">Team A</td> <td width="166">Team B</td> <td width="160">Team C</td> <td>Team D</td> </tr> <tr> <td width="155">Score</td> <td width="177"> <p align="center"> <input name="t1" size="22" value="0" style="border:3px double #FF0000; float: right"></td> <td width="166"> <input type="text" name="t2" size="22" value="0" style="border: 3px double #FF0000"></td> <td width="160"> <input type="text" name="t3" size="22" value="0" style="border: 3px double #FF0000"></td> <td> <input type="text" name="t4" size="22" value="0" style="border: 3px double #FF0000"></td> </tr> </table> </div> </form> <p align="center"> </p> </body> </html> Hi, I was working on this problem that asks me to return an array of scores for each string (only for its content part, not URL) in the global variable, which is an array. For example, alert a score of 0 if the string z is not found, 1 if found once, and 2 for twice. My problem is that I can get the code to alert if it has found the word (ex. "the"), but I cannot manage to : a) Assign separate scores for each string. b) Make the search case insensitive i.e. "the" will appear in 0,1, but not in 2, where it is capitalized I would appreciate any help! [CODE] var c = ["[www.facebook.com] Facebook is the best social networking site to coccent with your friends. ", "[www.google.co.uk] Google is the worldwide search engine. ", "[www.bbc.co.uk] The best news source for starting your day. "]; function findScore(z) { for (var i=0; i<c.length; i++) { var a = c[i].toString(); var b = a.search(z); if(b>-1) { alert (z + " found in array " + i); } } } findScore("the"); [CODE] Sorry for not being able to wrap the code! I am looking for a bit of Javascript that can hide a sentence in my website if the URL contains certain words, most specifically INFO or CERT. Any idea how I can do this? Your help is appreciated. Thank You, Kevin Brown I have a list of checkboxes, "group1","group2",etc. That have values of comma separated strings. such as 1,2,3,4,5. when a group is checked, I want all "individual" checkboxes to check if their value is found in that group. Group1 value="1,2,3" Group2 value="4,5,6" Group3 value="7,8,9" itemarray[] value="1" itemarray[] value="2" itemarray[] value="3" itemarray[] value="4" itemarray[] value="5" itemarray[] value="6" itemarray[] value="7" itemarray[] value="8" Found a thread that partially addressed this issue, but not for the comma separated string. See http://www.codingforums.com/showthread.php?t=115705 I know php, but have a hard time with javascript....I appreciate the help Thanks in Advance!! I'm new to coding and recently undertook the position as my school district's webmaster. We use a six day schedule where the days are labeled A-F. I want to be able to display the Today is...A graphic based on the date. I tried some scripts from other forums, but it does not appear to be working. Any suggestions? TY <code> <script language="javascript"> <!-- var picture=''; mytime=new Date(); mymonth=mytime.getMonth()+1; mydate=mytime.getDate(); if (mymonth==9 && mydate==13){picture="<img src=/images/d.gif>"; } if (mymonth==9 && mydate==14){picture="<img src=/images/e.gif width=150 height=150 alt=E>"; } if (mymonth==9 && mydate==15){picture="<img src=/images/f.gif width=150 height=150 alt=F>"; } if (mymonth==9 && mydate==16){picture="<img src=/images/A.gif width=150 height=150 alt=A>"; } if (mymonth==9 && mydate==19){picture="<img src=/images/B.gif width=150 height=150 alt=B>"; } if (mymonth==9 && mydate==20){picture="<img src=/images/c.gif width=150 height=150 alt=C>"; } //--> </script></code> Inside of here if you save as a .html and open it it will pull up the game a series of 5 boxes and 5 answers underneath, Currently those 5 answers correctly correlate with each box so you know what they are considering you don't have the .jpgs to display them. The one in bold is the "question" when you click on the one that correlates with the bold it should tell you Correct! 100. 100 being your score and if you get it wrong it will say sorry! and then take your score down to a 50 since you got 1 out of 2 wrong. The problem is when you get it wrong it also immediatly says Congrats! after you get it wrong So it will prompt a Sorry! alert and a Congrats! alert on the wrong answer. The second problem is after the user gets it right or wrong, I need it to re random the list of answers and images. Whilst keeping the score intact for up to 20 questions. Please help! Code: <body> <script type="text/javascript"> var counter = 0; var correct = 0; function show_alert0() { {counter++;} if (randomname0 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } function show_alert1() { {counter++;} if (randomname1 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } function show_alert2() { {counter++;} if (randomname2 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } function show_alert3() { {counter++;} if (randomname3 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } function show_alert4() { {counter++;} if (randomname4 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } </script> <script type="text/javascript"> var randomnumber0=Math.floor(Math.random()*66) var randomnumber1=Math.floor(Math.random()*66) var randomnumber2=Math.floor(Math.random()*66) var randomnumber3=Math.floor(Math.random()*66) var randomnumber4=Math.floor(Math.random()*66) while (randomnumber0==randomnumber1 || randomnumber0==randomnumber2 || randomnumber0==randomnumber3 || randomnumber0==randomnumber4) {randomnumber0=Math.floor(Math.random()*66)} while (randomnumber1==randomnumber0 || randomnumber1==randomnumber2 || randomnumber1==randomnumber3 || randomnumber1==randomnumber4) {randomnumber1=Math.floor(Math.random()*66)} while (randomnumber2==randomnumber0 || randomnumber2==randomnumber1 || randomnumber2==randomnumber3 || randomnumber2==randomnumber4) {randomnumber2=Math.floor(Math.random()*66)} while (randomnumber3==randomnumber0 || randomnumber3==randomnumber1 || randomnumber3==randomnumber2 || randomnumber3==randomnumber4) {randomnumber3=Math.floor(Math.random()*66)} while (randomnumber4==randomnumber0 || randomnumber4==randomnumber1 || randomnumber4==randomnumber2 || randomnumber4==randomnumber3) {randomnumber4=Math.floor(Math.random()*66)} document.write('<p style="text-align:center">') document.write('<em>Click on the ribbon that matches the name below.</em><br/><br/>') document.write('<button type="button" height="300" width="300" onclick="show_alert0()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber0+'.jpg" height="300px" width="200px"></button>') document.write('<button type="button" height="300" width="300" onclick="show_alert1()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber1+'.jpg" height="300px" width="200px"></button>') document.write('<button type="button" height="300" width="300" onclick="show_alert2()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber2+'.jpg" height="300px" width="200px"></button>') document.write('<button type="button" height="300" width="300" onclick="show_alert3()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber3+'.jpg" height="300px" width="200px"></button>') document.write('<button type="button" height="300" width="300" onclick="show_alert4()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber4+'.jpg" height="300px" width="200px"></button><br/>') document.write('</style>') var name = new Array(); name[0] = "Airman"; name[1] = "Airman 1st Class"; name[2] = "Senior Airman"; name[3] = "Staff Sergeant"; name[4] = "Technical Sergeant "; name[5] = "Master Sergeant"; name[6] = "First Master Sergeant"; name[7] = "Senior Master Sergeant"; name[8] = "First Senior Master Sergeant"; name[9] = "Chief Master Sergeant"; name[10] = "First Chief Master Sergeant"; name[11] = "Command Chief Master Sergeant"; name[12] = "Chief Master Sergeant of the Air Force"; name[13] = "2nd Lieutenant"; name[14] = "1st Lieutenant"; name[15] = "Captain"; name[16] = "Major"; name[17] = "Lieutenant Colonel"; name[18] = "Colonel"; name[19] = "Brigadier General"; name[20] = "Major General"; name[21] = "Lieutenant General"; name[22] = "General"; name[23] = "General of the ..."; name[24] = "Private"; name[25] = "Private 1st Class"; name[26] = "Specialist"; name[27] = "Corporal"; name[28] = "Sergeant"; name[29] = "Staff Sergeant"; name[30] = "Sergeant First Class"; name[31] = "Master Sergeant"; name[32] = "First Sergeant"; name[33] = "Sergeant Major"; name[34] = "Command Sergeant Major"; name[35] = "Sergeant Major of the Army"; name[36] = "Warrant Officer (W01)"; name[37] = "Chief Warrant Officer (CW2) "; name[38] = "Chief Warrant Officer (CW3)"; name[39] = "Chief Warrant Officer (CW4)"; name[40] = "Chief Warrant Officer (CW5)"; name[41] = "Private First Class"; name[42] = "Lance Corporal"; name[43] = "Corporal"; name[44] = "Sergeant"; name[45] = "Staff Sergeant"; name[46] = "First Sergeant"; name[47] = "Sergeant Major"; name[48] = "Master Gunnery Sergeant"; name[49] = "Warrant Officer (W0)"; name[50] = "Chief Warrant Officer (CW02)"; name[51] = "Chief Warrant Officer (CW03)"; name[52] = "Chief Warrant Officer (CW04)"; name[53] = "Chief Warrant Officer (CW05)"; name[54] = "Seaman Apprentice"; name[55] = "Seaman"; name[56] = "Petty Officer Third Class"; name[57] = "Petty Officer Second Class"; name[58] = "Petty Officer First Class"; name[59] = "Chief Petty Officer"; name[60] = "Second Chief Petty Officer"; name[61] = "Master Chief Petty Officer"; name[62] = "Fleet / Command Master Chief Petty Officer"; name[63] = "Master Chief Petty Officer of the Navy"; name[64] = "Chief Warrant Officer (CW02)"; name[65] = "Chief Warrant Officer (CW03)"; name[66] = "Chief Warrant Officer (CW04)"; var randomname0 = name[randomnumber0]; var randomname1 = name[randomnumber1]; var randomname2 = name[randomnumber2]; var randomname3 = name[randomnumber3]; var randomname4 = name[randomnumber4]; document.write(randomname0+'<br/>'+randomname1+'<br/>'+randomname2+'<br/>'+randomname3+'<br/>'+randomname4+'<br/>') var randomname = new Array(5); randomname[0] = name[randomnumber0]; randomname[1] = name[randomnumber1]; randomname[2] = name[randomnumber2]; randomname[3] = name[randomnumber3]; randomname[4] = name[randomnumber4]; var randomnamenum=Math.floor(Math.random()*4); var final=randomname[randomnamenum]; document.write('<br/><br/><pstyle="text-align:center"><strong>'+final+'</strong></style><br>') </script> </body> Hi Guys, i am wondering if there is a way to have an auto Complete form field from a db table data ? thanks Hi to every one. I'w created a mini javascript game for my site where you click on red button as fastest as you can for 10 seonds to achieve as best as you can click numbers per second. And the end score is a variable which I send to a function which reads the array that contains ten best scores and write your score in same array if it's among 10 best. Now I want to make somehow to save that array on server so I could read it on page load to show a high score list, but I'm having trouble to write that array in any kind of data on server that I could read it again from same data. I would be very grateful if someone can help me! I have been researching like crazy, and I can't find any information that seems to fit what I need! I am looking for a solution for the following problem: We have products that have multiple parts that can be colored separately from each other. In other words, if it was a shirt, the sleeves, graphic, front panel, pocket, and back panel could all be a different color. We have a range of color options available that can be up to 50. So, if I made a single image for each combination, we're looking at thousands of images here. How can I use scripts to build a page that can pick all of these options and combine them together in a product image for the customer? Is it even possible? I have tried layering 4 0r 5 images with relative and absolute positioning, and doing an image swap...but that is not something I can see us using on a regular basis. I must be missing something here. We've been looking around at other sites like Victorias Secret and Old Navy, and like their color changes....but theirs seem to only involve the single color layer. Thanks for any advice! Hi, I'm using javascript in addition to a web service (BTBuckets) to display different content to visitors based on actions they take on my site. The javascript is working fine, but I noticed that if I simulate BTBuckets being disabled using Firefox Adblock none of the content shows up. So in the off chance of the service going offline it'll leave some pretty funky holes in the my content. I tried <noscript> tags which works with javascript off, but the content is still blank when I disable BTBuckets. I'm wondering if there's a way to display the default content if the service is unavailable? Here's the code I'm using: In the head: Code: <script type="text/javascript"> //<![CDATA[[ $BTB={s:XXXXX}; $BTB.jsh="http://static.btbuckets.com/bt.js"; //]]> </script> <script type="text/javascript"> document.write(unescape("%3Cscript src='" + $BTB.jsh.replace(/(https?:)/i,document.location.protocol) + "' type='text/javascript'%3E%3C/script%3E")); </script> The code in the body used to replace an image depending on visitor behavior: Code: <script type="text/javascript"> var _t = ""; if ($BTB.clusters["ppc_visitors"]) { _t = "\"images/top-photo-tracking-number.jpg\" alt=\"Call Toll-Free: 1-800-XXX-XXXX\">"; } else { _t = "\"images/top-photo.jpg\" alt=\"Call Toll-Free: 1-800-XXX-XXXX\">"; } document.write('<img src= ' + _t ); </script> <noscript><img src="images/top-photo.jpg" alt="Call Toll-Free: 1-800-XXX-XXXX"></noscript> I have a web page created using plsql web toolkit. I want to set the text box values for street line 2 and zip based on user selection in select drop down which is street line 1. The select drop down list is based on a cursor selecting data from the Oracle database. I'm not sure if I need to use an array in the javascript code or if I can set the values some where in my package. Any advice would be appreciated. cursor: Quote: cursor bldglistc is select stvbldg_code, stvbldg_desc, slbbldg_street_line1, slbbldg_city, slbbldg_stat_code, slbbldg_zip from stvbldg, slbbldg where stvbldg_code = slbbldg_bldg_code (+) and stvbldg_desc not like 'DNU%' and stvbldg_desc not like 'Online%' order by slbbldg_bldg_code; bldg_record bldglistc%ROWTYPE; Javascript in package: Quote: htp.p(' <SCRIPT LANGUAGE="JavaScript" TYPE = "text/javascript"> function UpdateNextField(which1,which2,fld1,fld2) { document.getElementById(fld1).value = which1.value; document.getElementById(fld2).value = which2.value; } </SCRIPT> '); Form code from package: Quote: HTP.formopen ('bwgkogad.P_ProcAddrUpdate', 'post'); twbkfrmt.P_FormHidden ('atyp', atyp); twbkfrmt.P_FormHidden ('seqno', seqno); twbkfrmt.p_tableopen ( 'DATAENTRY', cattributes =>G$_NLS.Get('BWGKOAD1-0003','SQL','SUMMARY="This table shows Address Selected for Update."') ); twbkfrmt.p_tablerowopen; twbkfrmt.p_tabledataheader (stvatyp_rec.stvatyp_desc, ccolspan => '5'); twbkfrmt.p_tablerowclose; twbkfrmt.p_tablerowopen; twbkfrmt.p_tabledatalabel ( twbkfrmt.f_formlabel ( g$_nls.get ('BWGKOAD1-0007', 'SQL', 'Address Line 1:'), idname => 'street_line1_input_id' ) ); twbkfrmt.p_tabledataopen (ccolspan => '5'); HTP.formselectopen ( 'str1', '', 1, cattributes => 'ID="street_line1_input_id" onChange="javascript: UpdateNextField(this,this,''street_line2_input_id' ',''zip_input_id'')"' ); OPEN bldglistc; LOOP FETCH bldglistc INTO bldg_record; IF bldglistc%NOTFOUND THEN EXIT; END IF; IF address_rec.spraddr_street_line1 = bldg_record.slbbldg_street_line1 THEN twbkwbis.p_formselectoption ( bldg_record.slbbldg_street_line1, bldg_record.slbbldg_street_line1, 'selected' ); ELSE twbkwbis.p_formselectoption ( bldg_record.slbbldg_street_line1, bldg_record.slbbldg_street_line1 ); END IF; END LOOP; CLOSE bldglistc; HTP.formselectclose; twbkfrmt.p_tabledataclose; twbkfrmt.p_tablerowclose; twbkfrmt.p_tablerowopen; twbkfrmt.p_tabledatalabel ( twbkfrmt.f_formlabel ( g$_nls.get ('BWGKOAD1-0008', 'SQL', 'Address Line 2:'), idname => 'street_line2_input_id' ) ); twbkfrmt.p_tabledata ( twbkfrmt.f_formtext ( 'str2', 70, 75, address_rec.spraddr_street_line2, cattributes => 'ID="street_line2_input_id" readonly' ), ccolspan => '5' ); twbkfrmt.p_tablerowclose; twbkfrmt.p_tablerowopen; twbkfrmt.p_tabledatalabel ( twbkfrmt.f_formlabel ( g$_nls.get ('BWGKOAD1-0013', 'SQL', 'ZIP or Postal Code:'), idname => 'zip_input_id' ) ); twbkfrmt.p_tabledata ( twbkfrmt.f_formtext ( 'zip', NULL, 30, address_rec.spraddr_zip, cattributes => 'ID="zip_input_id" readonly' ), ccolspan => '5' ); twbkfrmt.p_tablerowclose; twbkfrmt.p_tableclose; HTP.para; -- HTP.formsubmit (NULL, G$_NLS.Get('BWGKOAD1-0054','SQL','Submit')); HTP.formreset (g$_nls.get ('BWGKOAD1-0055', 'SQL', 'Reset')); HTP.formclose; Hi, I've made a web based tool that times how long a web page takes to load in an iframe and today I redesigned it but now it has issues. When I load it in Chrome and Opera the new version works fine but in FF 3.6 and IE 8 only the footer area is displayed. I have added the links below - You'll be able to access the code via your browser's "View page Source" option. URLs: New test (With problem): http://browserspeedtest.camerongray....net/version31/ Old test (Works perfectly): http://browserspeedtest.co.cc Any help is greatly appreciated! Cameron Gray Dear all, background information: I did code a timesheet management system for my company with PHP where the user has to submit time entries and has an online form with several start and end times. The start and end times are all simple HTML select option dropdowns. I want that the first End time selection will be the next start time selection. Basically a simple dependency of the dropdown. My approach was that I want to solve this with JavaScript. In my php code I am echoing the following (in this select the end times are the values): echo "<select class='normal' name='$field_id' onChange=set_time_hour(this.value,'$field_id_js')>"; When the user changes then the end time dropdown the next field (next start time entry) should be changed accordingly. The javascript looks like this function set_time_hour(hour_value,next_field){ alert (hour_value); alert (next_field); document.getElementById(next_field).value = hour_value; } The alert calls are giving me the right values. but the document.getElementById(next_field).value = hour_value; is not working. What is wrong there? Do you have an idea? How can I change the value of a select box with Javascript? The select box values are already popoluated with PHP so I just want to select the right value. I have a form that has a pretty complicated combo box - a user starts typing text, it queries a database for matches, and displays the results to the user. The user can then select the match they desire and it has a value id, which I am currently sending to a hidden field in the form. So, for example: user starts typing in a movie name, Seven - it returns Seven and user selects it. The form submits the id of the movie seven (say 12) to a hidden field. Where I am stumped: Once a user selects a movie title, I have another drop down select box that is to display the available formats of the movie by querying my database based on the product id (12) and returning the available formats in the list: DVD BLUERAY VHS I am pretty good at programming, but I cannot figure this out - how to make the select box fire and return results once the value for the textbox has been captured. Can anyone help me? Is there a way to call javascript functions based on the text between a span element? In other words if I have <span id="mySpan">Bronze</span> then it will call a javascript function but if I have <span id="mySpan">Silver</span> then it will call a different function? Thanks! This is what I tried but alas, it does not work por que no? This is located on my main index file which if the result of z is greater than 1, I would have the user stay at this page as opposed to redirecting to the portrait design. I have optimized the website for mobile use so there is a reason of having two different pages, the wide screen has extra tools / other stuff that isn't shown on the portrait not because of size/responsive design but becasue I want it to be this way. Anyway... "What's the situation captain?" This is located above my <style> tag Code: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script language="JavaScript" type="text/javascript"> <script> function redirect() { var x = screen.width; var y = screen.height; var z = x/y; if (z<1) { window.location.replace("alternate destination"); }; else ( ){ // stay here }; }; </script> Reply With Quote 12-21-2014, 01:58 AM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts You have extra semicolons in there. In general, don't put a semicolon directly after a right brace }; There are a couple of exceptions, but they don't apply here. What's the point in having the else?? I am facing an issue where a link on my website opens in a new window if you simply click on it. However, if you right click and say open in new window or new tab, it opens the same window (URL) again from where the link is clicked. Self Service Option is a link and the JSP calls a function getSelfServSite() when the link is clicked. This is how the code flows in my case function getSelfServSite() { getToTheLink("${myConfigInfo.selfServiceURL}"); // this is because the URL is configurable } function getToTheLink(url) { window.open (url, "currentWindow", ""); } What am I doing wrong. I want it to go to the right link no matter how the user click it. Please advise. Thanks Hi, I've just created an image based digital clock following a youtube tutorial, and I understand all of it except one thing. I have created a regular digital clock (a text one), and then split this into an array. So I can manipulate the hours/ mins/ secs with [0],[1] and [2], is this the element that makes my regular text into the images I am using? There must be a correlation between the two, and that's all I can see that would do that for me. Here is the code: Code: digit_Images = ["d0.jpg","d1.jpg","d2.jpg","d3.jpg","d4.jpg","d5.jpg","d6.jpg","d7.jpg","d8.jpg","d9.jpg", "d10.jpg","d11.jpg","d12.jpg"] for (i=0;i<digit_Images.length;i++){ document.write('<img style="display: none;" src="' + digit_Images[i] + '" />'); } function clock_final(){ //make time object the_Date = new Date(); current_Time = the_Date.getHours() + ":" + the_Date.getMinutes() + ":" + the_Date.getSeconds(); var time_Parts = current_Time.split(":"); //am or pm if (time_Parts[1] <=12){ var AM_PM = digit_Images[11]; } else{ var AM_PM = digit_Images[12]; } //split down to 12 hour clock by subtracting 12 if (time_Parts[0]>=13){ time_Parts[0] = time_Parts[0] - 12 + ""; } else if(time_Parts[0] =="0"){ time_Parts[0] = "12"; } var the_Clock = new Array(); for (var i = 0; i < time_Parts.length; i++) { if (time_Parts[i].length == 1) { the_Clock[i] = '<img src="' + digit_Images[0] + '" />' + '<img src="' + digit_Images[parseInt(time_Parts[i])] + '" />'; } else if (time_Parts[i].length ==2) { the_Clock[i] = '<img src="' + digit_Images[parseInt(time_Parts[i].charAt(0))] + '" />' + '<img src="' + digit_Images[parseInt(time_Parts[i].charAt(1))] + '" />'; } } var clockHTMLInput = the_Clock[0] + '<img src="' + digit_Images[10] + '" />' + the_Clock[1] + '<img src="' + digit_Images[10] + '" />' + the_Clock[2] + '<img src="' +AM_PM + '" />'; document.getElementById('clock').innerHTML = clockHTMLInput; } Hope that's not too jumbled. Thanks. Probably a simple question but it's got me stumped, this post on codingforums didn't really help me either. I have 5 divs, and I want to have each of them visible seperately on a certain weekday. In pseudo-code: Code: if today=monday, show div "bla1" if today=tuesday, show div "bla2" etc. "bla2" should not be visible if it's monday, etc. I've struggled with trying to bend existing scripts to this purpose but I can't get it working. Please help! |