JavaScript - Help Needed For A Survey Form Points Computation Code
This is the code that I'm presently using:
Code: <script language="JavaScript" type="text/javascript"> <!-- function Cal(obj){ var total=0; var ticked=0; for (var zxc0=1;zxc0<obj['B'].length;zxc0++){ if (obj['B'][zxc0].checked){ total+=obj['B'].length-1; ticked+=zxc0; } } for (var zxc1=1;zxc1<obj['C'].length;zxc1++){ if (obj['C'][zxc1].checked){ total+=obj['C'].length-1; ticked+=zxc1; } } for (var zxc2=1;zxc2<obj['D'].length;zxc2++){ if (obj['D'][zxc2].checked){ total+=obj['D'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['E'].length;zxc2++){ if (obj['E'][zxc2].checked){ total+=obj['E'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['F'].length;zxc2++){ if (obj['F'][zxc2].checked){ total+=obj['F'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['G'].length;zxc2++){ if (obj['G'][zxc2].checked){ total+=obj['G'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['H'].length;zxc2++){ if (obj['H'][zxc2].checked){ total+=obj['H'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['I'].length;zxc2++){ if (obj['I'][zxc2].checked){ total+=obj['I'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['J'].length;zxc2++){ if (obj['J'][zxc2].checked){ total+=obj['J'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['K'].length;zxc2++){ if (obj['K'][zxc2].checked){ total+=obj['K'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['L'].length;zxc2++){ if (obj['L'][zxc2].checked){ total+=obj['L'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['M'].length;zxc2++){ if (obj['M'][zxc2].checked){ total+=obj['M'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['N'].length;zxc2++){ if (obj['N'][zxc2].checked){ total+=obj['N'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['O'].length;zxc2++){ if (obj['O'][zxc2].checked){ total+=obj['O'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['P'].length;zxc2++){ if (obj['P'][zxc2].checked){ total+=obj['P'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['Q'].length;zxc2++){ if (obj['Q'][zxc2].checked){ total+=obj['Q'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['R'].length;zxc2++){ if (obj['R'][zxc2].checked){ total+=obj['R'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['S'].length;zxc2++){ if (obj['S'][zxc2].checked){ total+=obj['S'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['T'].length;zxc2++){ if (obj['T'][zxc2].checked){ total+=obj['T'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['U'].length;zxc2++){ if (obj['U'][zxc2].checked){ total+=obj['U'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['V'].length;zxc2++){ if (obj['V'][zxc2].checked){ total+=obj['V'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['W'].length;zxc2++){ if (obj['W'][zxc2].checked){ total+=obj['W'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['X'].length;zxc2++){ if (obj['X'][zxc2].checked){ total+=obj['X'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['W'].length;zxc2++){ if (obj['W'][zxc2].checked){ total+=obj['W'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['X'].length;zxc2++){ if (obj['X'][zxc2].checked){ total+=obj['X'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['Y'].length;zxc2++){ if (obj['Y'][zxc2].checked){ total+=obj['Y'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['Z'].length;zxc2++){ if (obj['Z'][zxc2].checked){ total+=obj['Z'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AA'].length;zxc2++){ if (obj['AA'][zxc2].checked){ total+=obj['AA'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AB'].length;zxc2++){ if (obj['AB'][zxc2].checked){ total+=obj['AB'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AC'].length;zxc2++){ if (obj['AC'][zxc2].checked){ total+=obj['AC'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AD'].length;zxc2++){ if (obj['AD'][zxc2].checked){ total+=obj['AD'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AE'].length;zxc2++){ if (obj['AE'][zxc2].checked){ total+=obj['AE'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AF'].length;zxc2++){ if (obj['AF'][zxc2].checked){ total+=obj['AF'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AG'].length;zxc2++){ if (obj['AG'][zxc2].checked){ total+=obj['AG'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AH'].length;zxc2++){ if (obj['AH'][zxc2].checked){ total+=obj['AH'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AI'].length;zxc2++){ if (obj['AI'][zxc2].checked){ total+=obj['AI'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AJ'].length;zxc2++){ if (obj['AJ'][zxc2].checked){ total+=obj['AJ'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AK'].length;zxc2++){ if (obj['AK'][zxc2].checked){ total+=obj['AK'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AL'].length;zxc2++){ if (obj['AL'][zxc2].checked){ total+=obj['AL'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AM'].length;zxc2++){ if (obj['AM'][zxc2].checked){ total+=obj['AM'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AN'].length;zxc2++){ if (obj['AN'][zxc2].checked){ total+=obj['AN'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AO'].length;zxc2++){ if (obj['AO'][zxc2].checked){ total+=obj['AO'].length-1; ticked+=zxc2; } } obj['Score'].value='Sco '+ticked+'/'+total; } //--> </script> However, what this piece of code does is that, every radio button gets only 1 point. What I intended is that every subsequent radio button in each <td> garners incremental points by 1. Eg: Q1, 1st radio button gets 0pt, 2nd radio button gets 1pt, 3rd radio button gets 2pt. Does anyone have any idea how to implement that, all help are greatly appreciated! Similar Tutorialscan anyone help me validate a survey page i have? it has many questions and each question has 5 radio buttons. i followed many guides and none of them worked for me. I refered to http://www.dynamicdrive.com/forums/s...00&postcount=9 guide and http://javascript.about.com/library/blradio4.htm but for somereason it doesn't seem to work. So can u guys plz look over my simplified version of the survey and see whats is wrong. Sorry if i sound like a noob, I am new here. Code: <!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>Untitled Document</title> <script type="text/javascript"> var btn = valButton(form.q1); if (btn == null) alert('No radio button selected'); else alert('Button value ' + btn + ' selected'); function valButton(btn) { var cnt = -1; for (var i=btn.length-1; i > -1; i--) { if (btn[i].checked) {cnt = i; i = -1;} } if (cnt > -1) return btn[cnt].value; else return null; } </script> </head> <body> <table width="800" border="1" cellspacing="0" cellpadding="20"> <form name="science" method="post" action="ad.html" onsubmit="return valButton(btn);"> <tr> <td width="475"><h3> <center> Reasons for organizing Science Olympiad </center> </h3></td> <td width="17"><h3> <center> 1 </center> </h3></td> <td width="17"><h3> <center> 2 </center> </h3></td> <td width="17"><h3> <center> 3 </center> </h3></td> <td width="17"><h3> <center> 4 </center> </h3></td> <td width="17"><h3> <center> 5 </center> </h3></td> </tr> <tr> <td width="475">1. It is fun</td> <td width="17"><input type="radio" id="q1" name="q1" value="1" /></td> <td width="17"><input type="radio" id="q1" name="q1" value="2" /></td> <td width="17"><input type="radio" id="q1" name="q1" value="3" /></td> <td width="17"><input type="radio" id="q1" name="q1" value="4" /></td> <td width="17"><input type="radio" id="q1" name="q1" value="5" /></td> </tr> <tr> <td>2. To motivate students to pursue further education in Science and Engineering</td> <td width="17"><input type="radio" id="q2" name="q2" value="1" /></td> <td width="17"><input type="radio" id="q2" name="q2" value="2" /></td> <td width="17"><input type="radio" id="q2" name="q2" value="3" /></td> <td width="17"><input type="radio" id="q2" name="q2" value="4" /></td> <td width="17"><input type="radio" id="q2" name="q2" value="5" /></td> </tr> <tr> <td><input type="submit" name="submit" /></td> </tr> <tr></tr> </form> </table> testing </body> </html> Hello, I am in the process of using the split function for splitting strings into an array. The problem I am dealing with is how to do this with local language. Not all languages us the space " " delimiter between words to write a phrase or sentence. I have a list of all of delimiters for english, japanese, chinese, korean in Decimal Code Point format. For example, the decimal code point equivalent for " " is 32. Is it possible to use the javascript split function with decimal code points? If not, how can I reformat them into a format that js would understand? Many thanks. here is the html code that i have PHP Code: <td valign="middle" valign="middle"> <input type="radio" name="gender" id="genderM" value="Male" /> Male <input type="radio" name="gender" id="genderFM" value="Female" /> Female </td> and here is the js funtion PHP Code: var $j = jQuery.noConflict(); function isValidEmail(str) { return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); } function validateForm(){ var firstName; var lastName; var email; var mobile; var comment; var error; firstName = $j('#firstName').val(); lastName = $j('#lastName').val(); email = $j('#email').val(); mobile = $j('#mobile').val(); comment = $j('#comment').val(); if(firstName=='' || firstName.length < 3){ error = 'Please Enter Your First Name'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(lastName=='' || lastName.length < 3){ error = 'Please Enter Your Second Name'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } //mob //$jmob_pattern = '^\d{10}$j'; if(mobile.length != 10 || isNaN(mobile)){ error = 'Please Enter Your Mobile Number'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(email=='' || !isValidEmail(email)){ error = 'Please Enter Your Email Address'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(comment.length < 5){ error = 'Please Enter A Comment'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } return true; } Does anybody know how i check to see if the radio button is select and also can anybody tell me how i can check for an email in the correct format the function isValidEmail in the above alows emails to pass through if they are in this format aaa@aaa. i only want them to go through if they are aaa@aaa.com Thanks for your help if you give it Hi.. I have this function: Code: function doz(oText){ var P27_max = document.getElementById("P27_max").value; //var P27_max_convert = parseFloat(P27_max) + parseFloat(1); var P27_max_convert = ((parseFloat(P27_max) * parseFloat(1000)) / parseFloat(0.00) / parseFloat(12)); if( !isNaN(P27_max_convert) ){ var P27_maxdoz = document.getElementById("P27_maxdoz").value = P27_max_convert.toFixed(2); } var P28_max = document.getElementById("P28_max").value; // var P28_max_convert = parseFloat(P28_max) + parseFloat(2); var P28_max_convert = ((parseFloat(P28_max) * parseFloat(1000)) / parseFloat(22.00) / parseFloat(12)); if( !isNaN(P28_max_convert) ){ var P28_maxdoz = document.getElementById("P28_maxdoz").value = P28_max_convert.toFixed(2); } } my output is Infinity.. what's wrong in my computation : var P28_max_convert = ((parseFloat(P28_max) * parseFloat(1000)) / parseFloat(22.00) / parseFloat(12)); Thank you Hi.. I have forms and I only need to input is the Demanded Qty, and from Demanded Qty that I input it will compute the demanded qty for each Item Code. Now my problem is I don't know on how can it possible that while i input the quantity it will also autodisplay the demanded qty for each materials. Noted: the Demanded Qty that will auto display is display only on the Demanded Qty you input per Items. For Example: On Item = P28 i input demanded qty, only on the ItemCode will display the output. and when i input on P30 the computation will display on the ItemCode for P30. here is my code: PHP Code: <?php error_reporting(0); date_default_timezone_set("Asia/Singapore"); //set the time zone $con = mysql_connect('localhost', 'root',''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); ?> <html> <title>Stock Requisition</title> <head> <link rel="stylesheet" type="text/css" href="kanban.css"> <script type="text/javascript"> function compute_quantity(){ var DemandedQty = document.getElementById('DemandedQty').value; var Quantity = document.getElementById('Quantity').value; var SubQty = (DemandedQty * Quantity); } </script> </head> <body> <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div> <table> <thead> <th>Items</th> <th>Sub Items</th> <th>Item Code</th> <th>Demanded Qty</th> <th>UoM</th> <th>Class</th> <th>Description</th> <th>BIN Location</th> </thead> <?php $DemandedQty = $_POST['DemandedQty']; $sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items"; $res_bom = mysql_query($sql, $con); while($row = mysql_fetch_assoc($res_bom)){ $Items = $row['Items']; $Items_ = substr($Items, 12, 3); echo "<tr> <td style='border: none;font-weight: bold;'> <input type='name' value='$Items_' name='Items_[]' id='Items' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border:none;'> </td> <td style='border:none;'> </td> <td style='border: none;'><center><input type='text' name='DemandedQty[]' id='DemandedQty' value='' size='12' onkeypress = compute_quantity()></center></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation, Quantity FROM bom_subitems WHERE Items = '$Items' ORDER BY Items"or die(mysql_error()); $res_sub = mysql_query($sql, $con); while($row_sub = mysql_fetch_assoc($res_sub)){ $Items1 = $row_sub['Items']; $SubItems = $row_sub['SubItems']; $ItemCode = $row_sub['ItemCode']; $UoM = $row_sub['UoM']; $Class = $row_sub['Class']; $Description = $row_sub['Description']; $BINLocation = $row_sub['BINLocation']; $Quantity = $row_sub['Quantity']; echo "<input type='hidden' name='Quantity' id='Quantity' value='$Quantity'>"; echo "<tr> <td style='border: none;'> <input type='hidden' value='$Items1' id='Items1' name='Items1[]'></td> <td style='border: none;'> <input type='text' name='SubItems[]' value='$SubItems' id='SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='ItemCode[]' value='$ItemCode' id='ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'><center><input type='text' name='SubQty[]' id='SubQty' value='' size='12' style></center></td> <td style='border: none;' size='3'> <input type='text' name='UoM[]' value='$UoM' id='UoM' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='3'></td> <td style='border: none;'> <input type='text' name='Class[]' value='$Class' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size= '30'></td> <td style='border: none;'> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> </tr>"; } } ?> </table> </div> </form> </body> </html> Thank you so much Hello guys, I'm trying to basically build a survey that validates gender and age, and with those variables display the correct products for them. The problem is that the variables are not passing to the functions and not displaying nothing. Please help in this, here's my code: <iframe> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head><!-- Localized --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="robots" content="noindex,nofollow"> <title>Visitor Survey - Please Take A Minute...</title> <link href="survey_files/style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="survey_files/jquery.js"></script> <script> var genero = null; var edad = null; function q1() { $('#q1').hide(); $('#q2').show(); } function q2() { $('#q2').hide(); $('#q2').show(); } function q2() { $('#q2').hide(); $('#loader').show(); setTimeout(showProducts, 1500); } function setgender(g) { if (g == 'f') { genero = 'f'; } if (g == 'm') { genero = 'm'; } function setage (a) { if (a == '1017') { edad = '1017'; } if (a == '1825') { edad = '1825'; } if (a == '2639') { edad = '2639'; } if (a == '40') { edad = '40'; } } function showProducts() { $('#loader').hide(); $('#products').show(); if ( genero == 'f' && edad == '1017') { document.getElementById('fgift').style.display = 'block'; } if ( genero == 'm' && edad == '1017') { document.getElementById('mgift').style.display = 'block'; } } } </script> <style> .hoverspan { background-color:transparent; color:#000000; } .hoverspan:hover { background-color:#D9D9D9; color:#000000; } .btn { cursorointer; } .clear{clear:both;} html, body { height:100%; padding:0; margin:0; background-color:#D8D8D8; } #wrapper { min-height: 100%; height: auto !important; height: 100%; } .footer, .push { height: 4em; font-size:10px; width:90%; line-height:14px; padding:20px; text-align:center; } </style> </head><body> <div id="wrapper" style="margin: 0pt auto;"> <div id="content"> <div id="header" style="margin-left: 50px; padding-top: 12px;"> <img src="survey_files/thankyou.png" alt="Thank You" title="Thank You" border="0"> </div> <div id="leftbox" style="width: 306px; height: 336px;"> <p class="header">Dear Visitor,</p> <p>You've been selected to take part in our anonymous survey. Complete this 30 second questionnaire, and to say "thank you", we'll offer you a few exclusive prizes including a WalMart or Best Buy Gift Card. </p><p><br>This offer is available today only: <strong><script language="Javascript"> // Array of day names var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); // Array of month Names var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","Novem ber","December"); var now = new Date(); now.setDate(now.getDate()); document.write(dayNames[now.getDay()] + ", " + monthNames[now.getMonth()] + " " + (now.getDate()) + ", " + now.getFullYear()); // --> </script>Wednesday, January 26, 2011 </strong></p> </div> <div id="rightbox"> <form name=""> <div id="q1"> <p> </p> Question 1 of 3:<br> Are you male or female?<br> <div class="hoverspan" onclick="javascript:setgender('m'); javascript:q1();" style="padding: 2px; margin: 2px;"> <input id="q1_a1" onclick="javascript:setgender('m'); q1();" type="radio"><label id="male">Male</label> </div> <div class="hoverspan" onclick="javascript:setgender('f'); javascript:q1();" style="padding: 2px; margin: 2px;"> <input id="q1_a2" onclick="javascript:setgender('f'); q1();" type="radio"><label id="female">Female</label> </div> </div> <div id="q2" style="display: none;"> <p> </p> Question 2 of 3:<br> How old are you?<br> <div class="hoverspan" onclick="javascript:setage('1017'); javascript:q2();" style="padding: 2px; margin: 2px;"> <input id="q2_a1" onclick=" javascript:setage('1017'); q2();" type="radio"><label id="age">10-17</label> </div> <div class="hoverspan" onclick="javascript:setage('1825'); javascript:q2();" style="padding: 2px; margin: 2px;"> <input id="q2_a2" onclick="javascript:setage('1825'); q2();" type="radio"><label id="age">18-25</label> </div> <div class="hoverspan" onclick="javascript:setage('2639'); javascript:q2();" style="padding: 2px; margin: 2px;"> <input id="q2_a3" onclick=" javascript:setage('2639'); q2();" type="radio"><label id="age">26-39</label> </div> <div class="hoverspan" onclick="javascript:setage('40'); javascript:q2();" style="padding: 2px; margin: 2px;"> <input id="q2_a4" onclick="javascript:setage('40'); q2();" type="radio"><label id="age">40+</label> </div> </div> <div id="loader" style="display: none; text-align: center;"> <p> </p> <p>Thank you for your responses!</p> <p><img src="survey_files/loader.gif" alt="loading..." title="loading..."></p> <p>Submitting your answers...</p> </div> </form> <div id="products" style="display: none;"> <p>Thank you for participating in our survey! Please select your prize!</p> <div> <table id="fgift" style="display: none;" border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr id="gift2" class="hoverspan" onclick="PreventExitSplash=true; location.href='victorias.php';" style="cursor: pointer;"> <td style="padding: 0pt 5px 5px 0pt;"><img src="survey_files/vs2.jpg" id="vs"></td> <td class="mid"><p><b> $1,000 Victoria's Secret Gift Card</b></p> Quantity Left: 3</td> <td class="right" align="right"><form method="post" action="victorias.php"><input value="Choose Victoria's" class="btn" onclick="PreventExitSplash=true;" type="submit"></form></td> </tr></tbody></table> <table id="mgift" style="display: none;" border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr id="gift2" class="hoverspan" onclick="PreventExitSplash=true; location.href='walmart.php';" style="cursor: pointer;"> <td style="padding: 0pt 5px 5px 0pt;"><img src="survey_files/walmart.jpg" id="walmart"></td> <td class="mid"><p><b> $1,000 WalMart Gift Card</b></p> Quantity Left: 2</td> <td class="right" align="right"><form method="post" action="walmart.php"><input value="Choose WalMart" class="btn" onclick="PreventExitSplash=true;" type="submit"></form></td> </tr> </tbody></table> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody><tr id="gift2" class="hoverspan" onclick="PreventExitSplash=true; location.href='bestbuy.php';" style="cursor: pointer;"> <td style="padding: 0pt 5px 5px 0pt;"><img src="survey_files/bestbuy.jpg" id="bestbuy"></td> <td class="mid"><p><b> $1,000 Best Buy Gift Card</b></p>Quantity Left: 4</td> <td class="right" align="right"><form method="post" action="bestbuy.php"><input value="Choose Best Buy" class="btn" onclick="PreventExitSplash=true;" type="submit"></form></td> </tr> </tbody></table> </div> </div> </div> <div class="clear"></div> <div class="push"></div> </div> <div id="footer" class="footer" style="margin: -100px auto 0pt; text-align: center;"> </div> <embed src="survey_files/nifty.swf" quality="high" bgcolor="#FFFFFF" name="niftyPlayer1" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="1" width="1"> </div></body></html> </iframe> A single letter is taken from each word in the sentence. Unlike before, either the first or last letter is taken. The letter taken is decided by which of the first or last is "greater" (e.g. "b" > "a", "c" > "b", etc.) Here are some examples based on the above rules: "hello" translates to "o" because "o" is greater than "h". "goodbye" translates to "g" because "g" is greater than "e". Full sentence example: "wazdee apple love bic nooo more end" This sentence will decrypt to "welcome". Complete the decryptB function so that it decrypts messages with the new scheme. Here are some examples: var decryptB = function(message) { // Your code here } var result1 = decryptB("wazdee apple love bic nooo more end") console.log(result1) // This should be "welcome" var result2 = decryptB("bria loud fuzu antidote") console.log(result2) // This should be "blue" Reply With Quote 01-20-2015, 09:41 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,310 Thanks 82 Thanked 4,754 Times in 4,716 Posts See the page http://www.codingforums.com/rules.htm See rule 1.5 We helped you way way too much the last time you asked the first variant of this homework problem. This is really a very simple variation on that. And you don't even include the final version of the code you used last time, so somebody who didn't see the last answers would have to start all over again. Not very friendly to potential responders. What have you *TRIED*? If you came running here without even trying to solve this, shame on you. At least show what you have tried and explain what results you get and, if you can, what you think is going wrong. By the way: How is the user supposed to output an "a" character? You need an answer to that question, methinks. I have a vendor delivered java script code that I am currently customizing. The original code involves a user when selects a "check box" option value , a small function is called titled "VerifyAcctType". Currently when a user selects the check box some values are defaulted into the form. Now to this function code below i have to add logic when user selects the same check box option FIRST a small pop up window should appear which lists two radio buttons"I Agree to terms" and "I do not agree to terms" options , user need to select one of the options in the pop up to proceed. If the user agrees to terms then the control should go back to the "VerifyAcctType" function and proceed with remaining steps like before else if the user selects "I do not agree" the logic should not proceed further in "VerifyAcctType" function. Here is the current code tied to VerifyAcctType function ============================================== function VerifyAcctType(win,type) { var AcctType var ThisWindow var ThisForm if (win == "ADD") { ThisWindow = AddAccountWind ThisForm = AddAccountWind.document.addform } else if (win == "CHG") { ThisWindow = ChangeAccountWind ThisForm = ChangeAccountWind.document.chgform } if (type == "P") { <<I NEED NEW CODE HERE FOR THE POPUP>> Maccttype = type ThisForm.description.value = "My Company" ThisForm.comp_id.value = "1234567" ThisForm.comp_id.disabled = true } else { Maccttype = type ThisForm.description.value = "" ThisForm.comp_id.value = "" ThisForm.comp_id.disabled = false } } I am a java script beginner , any help is appreciated. I am still learning javascript so forgive me if this question is a bad one, I am making scripts for Greasemonkey for a website I am a part of. One of the developers recently commented out (in the source code) a feature that was available before. It is a Football MMORPG game and it used to show college players 40 times but over the past month he commented out the tag that held the script function. I want to know if i can either A) write a js code that can remove the comment tag in the source code or B) write a code that will just add another tag under that and have that js function that was commented out valid. I tried something but ended up just having that function pasted onto the page instead of having it put into the source to have it read by the rest of the data.. here is what im talking about <TABLE width=800 cellspacing=0> <tr> <td colspan=3 style="FONT-SIZE: 11pt"> <b>Hometown:</b>Fort Hunt, VA<br> <b>Height:</b>6-0<br> <b>Weight:</b>206<br> <!--b>40 Time:</b><if rs("team_id")>0 or bRated then><=formatnumber(rs("forty"),2)><br><end if --> i just want to see if there was any way to just delete the comment out of it so i can get this feature again is all. Any help would be awesome... and sorry for the long post Hi I am new to programming and I am trying to write a piece of code, I need the output to be a whole random number, this is what I have up to now : <SCRIPT language = "JavaScript"> //generate a random number greater than or equal to 0.0 and less than 50.0 //and display it in an alert dialogue window.alert("getRoundedRandomNumber: " Math.round + Math.random()*50); </SCRIPT> </HEAD> <BODY> <STRONG>A test of the random number functions <BR></STRONG> <FORM NAME = "randomForm"> <INPUT TYPE = "button" NAME = "randomButton" VALUE ="Display Random Number" ONCLICK = "window.alert(getRoundedRandomNumber(50));"> </FORM> can anyone advise me where I would put the Math.round function and how to make it work ? Thanks in advance I'm sorry I'm not to good at javascript. I know VB.net, but I have not learned javascript yet, and I need some help. I am working on a project to get a survey to pop up for new visitors on the index page of our site. What I need to do: on load look for a cookie, if that cookie is not found run a script telling the site to pull up another page in lightview using its own "on load" command. If the cookie is there the site will not open this other page. What I've done: I already found a way to do most of this, but I can only use a hyper link as a trigger for the site to load the other page in lightview. Here is a link of what I have so far: http://naomi-dr.com/template2.html Please let me know if you have any questions or need more information. 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> Hello everyone. I have been trying 2 days straight to figure out how to make this script work. Basically I am trying to have a hidden checkbox with a drop down menu. I want the user to be able to choose 0-9 where 0 the check box will not be checked and 1-9 if picked from the dropdown menu it will automatically check the hidden box. Here is the closest string of code I could find out there to help me figure it out but I am having no luck. The closest I got was....well I never really figured out how to make it work. Can someone please help me? Thanks. <script type="text/javascript"> function checkUncheck (selected) { var checkBox = document.getElementById("box"); if ((selected == 2) || (selected == 3)) { checkBox.checked = "checked"; } if ((selected == 0) || (selected == 1)) { checkBox.checked = "false"; } } </script> <form id="frm"> <table> <tr> <td><input type="checkbox" id="box" checked="false"/></td> <td> <select id="sel0" onchange="checkUncheck(this.selectedIndex)"> <option value="zero">zero</option> <option value="one">one</option> <option value="two">two</option> <option value="three">three</option> </select> </td> </tr> </table> </form> Can someone please suggest a good (and simple) code for password protecting one page on a site? I have a plan room for blueprints on my site. There will be multiple jobs at a given time and I need a page where we can give out a password to get the plans. Once the person logs in with user name and password for that day, he would then see file folders with the name of each job next to it. When he chooses a job, he clicks the folder to display a list of plans. If you can help with this or point me in a good direction, it would be greatly appreciated. Thanks for your help! hey guys. i need a js code that redirects to a flash page or to a non flash page after detecting the browsers plugin abilities and if it has flash or not. any help would be appriciated. cheers The problem: I can't get the code to send out my alerts due to empty radio groups. what I'm trying to accomplish: I want Javascript to send a alert to the user if none of the radio buttons within a group are checked. Short Summary: I'm new to Javascript and I've been trying to figure this out myself, but I honestly don't know what's wrong. If you guys can help that'd be great. Thanks in advance. and if the information that I've provided is in anyway confusing let me know and I'll try to help, but again my knowledge is limited. Here is a simplified version of my form.*There are originally 10 questions total. "Names: q1-q10"* Code: <html> <head> <script type="text/javascript" src="val.js"></script> </head> <body> <form method="POST" name="theForm" onsubmit="javascript:check();" class="surv_style" > <p class="ttl" ><label>Question 1: </label></p> <p><label> <input type="radio" name="q1" value="yes"> Yes </label></p> <p><label> <input type="radio" name="q1" value="some"> Sometimes </label></p> <p><label> <input type="radio" name="q1" value="no"> No </label></p> <p class="ttl" ><label>Question 2: </label></p> <p><label> <input type="radio" name="q2" value="yes"> Yes </label></p> <p><label> <input type="radio" name="q2" value="somet"> Sometimes</label></p> <p><label> <input type="radio" name="q2" value="no"> No</label></p> <p><label> <input type="radio" name="q2" value="no_notice"> I havent noticed</label></p> <p class="ttl" ><label>Question 3: </label></p> <p><label> <input type="radio" name="q3" value="yes"> Yes </label></p> <p><label> <input type="radio" name="q3" value="somet"> Sometimes</label></p> <p><label> <input type="radio" name="q3" value="no"> No</label></p> <input type="submit" name="sub_butt" value="Submit"> </form> </body> </html> Here is my Javascript code: Code: function valR_butt(rbgn){ var formName = "theForm"; var form = document.form[formName]; var isChecked = false; var counter = form[rbgn].length; for(var x=0;x<counter;x++){ if(form[rbgn][x].checked==true){ isChecked=true; break; } } if(isChecked==false){ alert(errorMessage); return false; }else{ return true; } } function check(){ var q1 =validateRadioButton("q1"); if(q1==false){ alert("Please select a answer to question 1"); return false; } function check(){ var q2 =validateRadioButton("q2"); if(q1==false){ alert("Please select a answer to question 2"); return false; function check(){ var q3 =validateRadioButton("q3"); if(q1==false){ alert("Please select a answer to question 3"); return false; } alert("OK!\nYour selection is valid"); return true; } } I want to insert a link into an email that opens a new window of a specific size. All of the scripts I find require some code to be inserted into the <head> tag of the page. Obviously this will not work since I am inserting the link into an email. Is there a JavaScript code for opening a popup window that's not dependent on <head> code?
Hi everyone, im no expert in coding but i manage to get this bit of code together using some free source stuff and put in the links to my images ect, the problem now is i need each picture to be different sizes and each one to have a clickable link but i am completely stumped heres the code Code: <html> <head> <script type="text/javascript"> <!-- var image1=new Image() image1.src="http://gohelp.org.uk/wp-content/uploads/2011/05/Charity-Rallies-World.png" var image2=new Image() image2.src="http://gohelp.org.uk/wp-content/uploads/2011/05/ROTW-logo.jpg" var image3=new Image() image3.src="http://gohelp.org.uk/wp-content/uploads/2011/05/Mongolia-Charity-Rally-Logo-Transparent.png" //--> </script> </head> <body> <center><img src="http://gohelp.org.uk/wp-content/uploads/2011/05/Charity-Rallies-World.png" name="slide" width="150" height="68" /></center> <script> <!-- //variable that will increment through the images var step=1 function slideit(){ //if browser does not support the image object, exit. if (!document.images) return document.images.slide.src=eval("image"+step+".src") if (step<3) step++ else step=1 //call function "slideit()" every 2.5 seconds setTimeout("slideit()",2500) } slideit() //--> </script> </body> </html> |