JavaScript - Radio Buton Select Only One
I need help please I have two radio button for default is NOT selected.
I need to have end user to select only one NOT both if any body can help me with these. PHP Code: function check_order ($Des, $Sed) { // sed = Serve_Date global $Trans; $Des = substr (tagfilter ($Des), 0, 20) . date2d ($Sed); if ($Trans[$Des] > 0) { return "checked"; } else { return ""; } } function check_double ($Des, $Sed) { // sed = Serve_Date global $Trans; $Des = substr (tagfilter ($Des), 0, 20) . date2d ($Sed); if ($Trans[$Des] == 2) { return "checked"; } else { return ""; } } here is my form: PHP Code: echo ("<input type=radio name=O$R[0] value=$R[0] " . check_order ($R[3], $R[1]) . ">"); echo("</td><td align=center>"); echo ("<input type=radio name=D$R[0] value=$R[0] " . check_double ($R[3], $R[1]) . ">"); Similar TutorialsAnother task please...I need to display the appropriate div when a radio button is selected... PHP Code: <body> <script type="text/javascript"> function checkjob(jobvalue){ if(jobvalue="type") { document.getElementById("type").style.display = "block"; }else if(jobvalue="select"){ document.getElementById("select").style.display = "block"; }else if(jobvalue="tag"){ document.getElementById("tag").style.display = "block"; } } </script><br /> <table width="200"> <tr> <td><label> <input type="radio" name="cat" value="type" id="cat_0" onchange="checkjob(this.value)" /> type</label></td><td><label> <input type="radio" name="cat" value="select" id="cat_1" onchange="checkjob(this.value)" /> select</label></td> <td><label> <input type="radio" name="cat" value="tag" id="cat_2" onchange="checkjob(this.value)" /> tag</label></td> </tr> </table> <div id="type" style="display:none"><input name="contact" type="text" /></div> <div id="tag" style="display:none">tag:<input name="contact" type="text" /></div> <div id="select" style="display:none"><select name=""> <option value="a" selected="selected">option 1</option> <option value="b">option 2</option> </select></div> </body> I have two drop down lists , list1, list 2. I want it to change according to the radio button selected by the user. If the user selects radio button1, lists1 should be displayed. If the user selects radio button2, lists2 should be displayed. How can i achieve this using javascript. Please somebody help me. Greetings! I'm trying to disable some form elements using the onclick from a radio input element. It ain't working so great! I googled around and finally scraped together some code that in theory 'I' think should work. I'm no javascript guru! It has to be some tiny tiny thing I'm missing. Here's my code and mind you this is a project in the making! I still have along way to go! Thanks for you time and help! 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" xml:lang="en"> <head> <title>Empty Page</title> <script type='text/javascript'> function setReadOnly(obj) { if(obj.value == "1") { document.shiftreport.artprogs.disabled = true; document.shiftreport.artprog_stat.disabled = true; } else { document.shiftreport.icprogs.disabled = true; document.shiftreport.icprog_stat.disabled = true; } } </script> </head> <body> <?php include_once('form_input_functions.php'); $artprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $artprog_wfls = array('no_job' => '------- select a job -------', 'ARTPROG/WFL/DAILY/BATCH' => 'ARTPROG/WFL/DAILY/BATCH', 'ARTPROG/WFL/OPERATIONS/IMAGE' => 'ARTPROG/WFL/OPERATIONS/IMAGE', 'ARTPROG/WFL/WKLY/BATCH' => 'ARTPROG/WFL/WKLY/BATCH', 'ARTPROG/WFL/DAILY/CLAIMS' => 'ARTPROG/WFL/DAILY/CLAIMS' ); $bllyprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $bllyprog_wfls = array('no_job' => '------- select a job -------', 'BLLYPROG/WFL/DAILY/SISCHEDPAY' => 'BLLYPROG/WFL/DAILY/SISCHEDPAY', 'BLLYPROG/WFL/DAILY/REPORTS' => 'BLLYPROG/WFL/DAILY/REPORTS', 'BLLYPROG/WFL/WKLY/REPORTS/GYPSUM' => 'BLLYPROG/WFL/WKLY/REPORTS/GYPSUM', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP', '$UTIL/O/AUDIT/CLOSE/BLLY' => '$UTIL/O/AUDIT/CLOSE/BLLY', 'DATASIWH/EXTRACTALL/DAILY/AUD/WFL' => 'DATASIWH/EXTRACTALL/DAILY/AUD/WFL', ); $sbwcprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $sbwcprog_wfls = array('no_job' => '------- select a job -------', 'WORKPROG/WFL/DAILY/WAREHOUSE' => 'WORKPROG/WFL/DAILY/WAREHOUSE', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP', '$UTIL/O/AUDIT/CLOSE/WORKCOMP' => '$UTIL/O/AUDIT/CLOSE/WORKCOMP' ); $tcsprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $tcsprog_wfls = array ('no_job' => '------- select a job -------', 'TCS/WFL/DAILY/BATCH' => 'TCS/WFL/DAILY/BATCH', 'BLPROG/WFL/COPY/REMOVE/GLCHECKS' => 'BLPROG/WFL/COPY/REMOVE/GLCHECKS' ); $icprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $icprog_wfls = array ('no_job' => '------- select a job -------', 'BLPROG/WFL/DAILY/INDCONT' => 'BLPROG/WFL/DAILY/INDCONT', 'INDCON/WFL/PRINT/IDCARDS' => 'INDCON/WFL/PRINT/IDCARDS', 'BLPROG/WFL/BATCH/NEWYORK/STATE-REPORT' => 'BLPROG/WFL/BATCH/NEWYORK/STATE-REPORT' ); $truckprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $truckprog_wfls = array('no_job' => '------- select a job -------', 'TRUCKPROG/WFL/DAILY/TKINTMARSH' => 'TRUCKPROG/WFL/DAILY/TKINTMARSH', 'TRUCKPROG/WFL/DAILY/TKINTERNET' => 'TRUCKPROG/WFL/DAILY/TKINTERNET', 'TRUCKPROG/WFL/DAILY/BATCH' => 'TRUCKPROG/WFL/DAILY/BATCH', 'TRUCKPROG/WFL/DAILY/TKSCHEDPAY' => 'TRUCKPROG/WFL/DAILY/TKSCHEDPAY', 'TRUCKPROG/WFL/DAILY/REPORTS' => 'TRUCKPROG/WFL/DAILY/REPORTS', 'BLPROG/WFL/DAILY/CLAIMS' => 'BLPROG/WFL/DAILY/CLAIMS', 'TRUCKPROG/WFL/DAILY/AUDIT/PREMIUM' => 'TRUCKPROG/WFL/DAILY/AUDIT/PREMIUM', 'TRUCKPROG/WFL/DAILY/BALRPT' => 'TRUCKPROG/WFL/DAILY/BALRPT', 'PROG-MEDICAL/WFL/DAILY/PMCLMEXT' => 'PROG-MEDICAL/WFL/DAILY/PMCLMEXT', 'AGPROG/WFL/DAILY/AGNUCOPREM' => 'AGPROG/WFL/DAILY/AGNUCOPREM', 'BL/WFL/WKLY/FEDEX/0005' => 'BL/WFL/WKLY/FEDEX/0005', 'TRUCKPROG/WFL/WKLY/DE542' => 'TRUCKPROG/WFL/WKLY/DE542', 'TRUCKPROG/WFL/WKLY/FDXDISAB' => 'TRUCKPROG/WFL/WKLY/FDXDISAB', 'TRUCKPROG/WFL/WKLY/FDXDISERR' => 'TRUCKPROG/WFL/WKLY/FDXDISERR', 'BL/WFL/ONLINE/DUMP/TRUCKING' => 'BL/WFL/ONLINE/DUMP/TRUCKING', 'DATATKWH/EXTRACTALL/DAILY/WFL' => 'DATATKWH/EXTRACTALL/DAILY/WFL', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' ); $smallprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $smallprog_wfls = array('no_job' => '------- select a job -------', 'SMALLPROG/WFL/DAILY/BATCH' => 'SMALLPROG/WFL/DAILY/BATCH', 'SMALLPROG/WFL/DAILY/CERTS' => 'SMALLPROG/WFL/DAILY/CERTS', 'SMALLPROG/WFL/OPERATIONS/PRINT' => 'SMALLPROG/WFL/OPERATIONS/PRINT', 'SMALLPROG/WFL/WKLY/BATCH' => 'SMALLPROG/WFL/WKLY/BATCH', 'SFCLAIMS/WFL/DAILY/DWHCLAIMS' => 'SFCLAIMS/WFL/DAILY/DWHCLAIMS', 'SFCLAIMS/WFL/DAILY/REPORTS' => 'SFCLAIMS/WFL/DAILY/REPORTS', 'SFCLAIMS/WFL/WEEKLY/REPORTS' => 'SFCLAIMS/WFL/WEEKLY/REPORTS', 'BL/WFL/ONLINE/DUMP/SFDB/1WORKER' => 'BL/WFL/ONLINE/DUMP/SFDB/1WORKER', '$UTIL/O/AUDIT/CLOSE/SFDB' => '$UTIL/O/AUDIT/CLOSE/SFDB', 'DATASFWH/EXTRACTALL/DAILY/WFL' => 'DATASFWH/EXTRACTALL/DAILY/WFL', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' ); $persauto_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $persauto_wfls = array('no_job' => '------- select a job -------', 'PERSAUTO/WFL/DAILY/BATCH' => 'PERSAUTO/WFL/DAILY/BATCH', 'PERSAUTO/WFL/OPERATIONS/IMAGE' => 'PERSAUTO/WFL/OPERATIONS/IMAGE', 'PERSAUTO/WFL/OPERATIONS/PRINT' => 'PERSAUTO/WFL/OPERATIONS/PRINT', 'PERSAUTO/WFL/WKLY/BATCH' => 'PERSAUTO/WFL/WKLY/BATCH', 'PERSAUTO/WFL/DAILY/CLAIMS' => 'PERSAUTO/WFL/DAILY/CLAIMS', 'BL/WFL/ONLINE/DUMP/DB1/1WORKER/FULL' => 'BL/WFL/ONLINE/DUMP/DB1/1WORKER/FULL', '$UTIL/O/AUDIT/CLOSE/DB1' => '$UTIL/O/AUDIT/CLOSE/DB1', 'DATAWH/EXTRACTALL/DAILY/WFL' => 'DATAWH/EXTRACTALL/DAILY/WFL', 'BL/WFL/OFFLINE/DUMP/WAREHOUSE' => 'BL/WFL/OFFLINE/DUMP/WAREHOUSE' ); $isoprog_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $isoprog_wfls = array('no_job' => '------- select a job -------', 'ISOPROG/WFL/BATCH/ISOSAGDAILY' => 'ISOPROG/WFL/BATCH/ISOSAGDAILY' ); $bkuplive_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $bkuplive_wfls = array('no_job' => '------- select a job -------', 'BL/WFL/ONLINE/DUMP/BLDB' => 'BL/WFL/ONLINE/DUMP/BLDB', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP', '$UTIL/O/AUDIT/CLOSE/BLDB' => '$UTIL/O/AUDIT/CLOSE/BLDB', 'DATARDWH/EXTRACTALL/DAILY/REIN/WFL' => 'DATARDWH/EXTRACTALL/DAILY/REIN/WFL', '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => '(BLPACK)BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP', 'BL/WFL/FICHE/DISK' => 'BL/WFL/FICHE/DISK' ); $testsite_status = array('none' => 'None', 'stopped' => 'Stopped', 'running' => 'Running', 'completed' => 'Completed', ); $testsite_wfls = array('no_job' => '------- select a job -------', 'WFL/TESTLYON/DATABASE/ONLINE/DISABLE' => 'WFL/TESTLYON/DATABASE/ONLINE/DISABLE', 'UTIL/WFL/REMOVE/TESTLYON/BDFILES' => 'UTIL/WFL/REMOVE/TESTLYON/BDFILES', 'BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' => 'BALDLYON/WFL/BLPACK/ARCHIVEANDBACKUP' ); ?> <form method="POST" name="shiftreport" action="<?php print $_SERVER['PHP_SELF']; ?>"> <p>1st Shift <?php input_radiocheck('radio','shift','0','1','1'); ?></p> <p>2st Shift <?php input_radiocheck('radio','shift','0','2','1'); ?></p> <p>3st Shift <?php input_radiocheck('radio','shift','0','3','1'); ?></p> <table> <thead> <tr> <th>Application</th> <th>Job Stream</th> <th>Status</th> </tr> </thead> <tbody> <tr> <td>ARTISAN</td> <td> <?php input_select('artprogs',$artprog_wfls['no_job'], $GLOBALS['artprog_wfls'], '390px'); ?> </td> <td> <?php input_select('artprog_stat', $artprog_status['none'] , $GLOBALS['artprog_status']); ?> </td> </tr> <tr> <td>SELF INSURED</td> <td> <?php input_select('bllyprogs',$bllyprog_wfls['no_job'], $GLOBALS['bllyprog_wfls'], '390px'); ?> </td> <td> <?php input_select('bllyprog_stat', $bllyprog_status['none'] , $GLOBALS['bllyprog_status']); ?> </td> </tr> <tr> <td>SBWC</td> <td> <?php input_select('sbwcprogs',$sbwcprog_wfls['no_job'],$GLOBALS['sbwcprog_wfls'], '390px'); ?> </td> <td> <?php input_select('sbwcprog_stat', $sbwcprog_status['none'] , $GLOBALS['sbwcprog_status']); ?> </td> </tr> <tr> <td>TCS</td> <td> <?php input_select('tcsprogs',$tcsprog_wfls['no_job'], $GLOBALS['tcsprog_wfls'], '390px'); ?> </td> <td> <?php input_select('tcsprog_stat', $tcsprog_status['none'] , $GLOBALS['tcsprog_status']); ?> </td> </tr> <tr> <td>IC</td> <td> <?php input_select('icprogs',$icprog_wfls['no_job'], $GLOBALS['icprog_wfls'], '390px'); ?> </td> <td> <?php input_select('icprog_stat', $icprog_status['none'] , $GLOBALS['icprog_status']); ?> </td> </tr> <tr> <td>TRUCKING</td> <td> <?php input_select('truckprogs',$truckprog_wfls['no_job'], $GLOBALS['truckprog_wfls'], '390px'); ?> </td> <td> <?php input_select('truckprog_stat', $truckprog_status['none'] , $GLOBALS['truckprog_status']); ?> </td> </tr> <tr> <td>SMALL FLEET</td> <td> <?php input_select('smallprogs',$smallprog_wfls['no_job'], $GLOBALS['smallprog_wfls'], '390px'); ?> </td> <td> <?php input_select('smallprog_stat', $smallprog_status['none'] , $GLOBALS['smallprog_status']); ?> </td> </tr> <tr> <td>PERSONAL AUTO</td> <td> <?php input_select('persauto',$persauto_wfls['no_job'], $GLOBALS['persauto_wfls'], '390px'); ?> </td> <td> <?php input_select('persauto_stat', $persauto_status['none'] , $GLOBALS['persauto_status']); ?> </td> </tr> <tr> <td>ISO</td> <td> <?php input_select('isoprog',$isoprog_wfls['no_job'], $GLOBALS['isoprog_wfls'], '390px'); ?> </td> <td> <?php input_select('isoprog_stat', $isoprog_status['none'] , $GLOBALS['isoprog_status']); ?> </td> </tr> <tr> <td>BACKUPS LIVE</td> <td> <?php input_select('bkuplive',$bkuplive_wfls['no_job'], $GLOBALS['bkuplive_wfls'], '390px'); ?> </td> <td> <?php input_select('bkuplive_stat', $bkuplive_status['none'] , $GLOBALS['bkuplive_status']); ?> </td> </tr> <tr> <td>TEST SITE INSTRUCTIONS</td> <td> <?php input_select('testsite',$testsite_wfls['no_job'], $GLOBALS['testsite_wfls'], '390px'); ?> </td> <td> <?php input_select('testsite_stat', $testsite_status['none'] , $GLOBALS['testsite_status']); ?> </td> </tr> </tbody> </table> </form> </body> </html> The included functions file that I didn't include is below: Code: <?php function input_text($element_name, $value) { print '<input type="text" name="' . $element_name . '" value="'; print htmlentities($values[$element_name]) . '">'; } function input_submit($element_name,$label) { print '<input type="submit" name="' . $element_name .'" value="'; print htmlentities($label) .'"/>'; } function input_textarea($element_name,$values) { print '<textarea name="' . $element_name . '">'; print htmlentities($values[$element_name]) . '</textarea>'; } function input_radiocheck($type,$element_name,$values,$element_value,$clicker = '0') { print '<input type="' . $type . '" name="' . $element_name . '" value="' . $element_value . '" '; if ($element_value == $values[$element_name]) { print ' checked="checked"'; } if ($clicker == '1') print ' onclick="setReadOnly(this)"'; print '/>'; } function input_select($element_name, $selected, $options, $drop_width = '100px', $multiple = false) { print '<select style="width:' . $drop_width . ';" name="' . $element_name; if ($multiple) { print '[]" multiple="multiple'; } print '">'; $selected_options = array(); if ($multiple) { foreach ($selected[$element_name] as $val) { $selected_options[$val] = true; } } else { $selected_options[ $selected[$element_name] ] = true; } foreach ($options as $option => $label) { print '<option value="' . htmlentities($option) . '"'; if (isset($selected_options[$option])) { print ' selected="selected"'; } print '>' . htmlentities($label) . '</option>'; } print '</select>'; } ?> I have 4 rows in a table. Each row consist of 4 radio buttons. Each radio button per row has different values in it but has the same name (group) ex: <input type="radio" name="a" value="1"> <input type="radio" name="a" value="2"> <input type="radio" name="a" value="3"> <input type="radio" name="a" value="4"> <input type="radio" name="b" value="1"> <input type="radio" name="b" value="2"> <input type="radio" name="b" value="3"> <input type="radio" name="b" value="4"> and so on.. If I click radio button A with value 2, I want to output the total at the bottom as "2".. Also, if I click radio button B with value 3, I want to output the total of A and B as 5 and so on.. How can I automatically calculate the answer based on which radio button was click? update: I got my answer from this site: http://stackoverflow.com/questions/1...s-using-jquery I've been having problems getting my select option to change the options of another select option. I'm not much of a javacsript coder, so I'm at a lost. When I select the first option nothing appears in the second option. here's the javascript code: Code: function createOption(OptionText, OptionValue){ var temp = document.captcha_form("option"); temp.innerHTML = OptionText; temp.value = OptionValue; return temp; } function valChange(){ var firstList = document.getElementById("emailaddress"); var secondList = document.getElementById("subject"); while(secondList.hasChildNodes()) secondList.removeChild(secondList.childNodes[0]); switch(firstList.value){ case "1":{ secondList.appendChild(createOption("Report Site Browsing Issue", Report Site Browsing Issues)); secondList.appendChild(createOption("Report Page Errors", Report Page Errors)); secondList.appendChild(createOption("Other", Other)); break; } case "2":{ secondList.appendChild(createOption("Report Unauthorized Game", Report Unauthorized Game)); secondList.appendChild(createOption("Report Spam", Report Spam)); secondList.appendChild(createOption("Report Harassment", Report Harassment)); secondList.appendChild(createOption("Report Illegal Activities", Report Illegal Activities)); secondList.appendChild(createOption("Request Account Removal", Request Account Removal)); break; } // .... default:{ secondList.appendChild(createOption("Please select from the first list", "")); break; } } } window.onload = valChange; this is the form code Code: <div class="mailto_form"> <form method="POST" id="captcha_form" name="captcha_form" action="../includes/mailform.php"> <div style="padding-bottom: 1em;">Choose Recipient: <select name="emailaddress" id="emailaddress" onchange="valChange();"> <option value=""></option> <option value="1">Webmaster</option> <option value="2">Admin</option> </select> </div> <div style="padding-bottom: 1em;">Subject: <br /><select name="subject" id="subject"> </div> <div style="padding-bottom: 1em;">From: <br /><input type="text" name="email" id="email" value=""> </div> <div style="padding-bottom: 1em;">Enter the text contained in the image into the text box: <br /><img src="../includes/captcha.php" /> <br /><input type="text" name="userpass" value=""> </div> <div style="padding-bottom: 1em;">Message: <br /><textarea name="message" id="message" rows="10" cols="60"><?php echo "</tex" . "tarea>"; ?> </div> <div style="padding-bottom: 1em;"><input name="submit" type="submit" value="Submit"> </div> </form> </div> Link to the page http://www.netgamegurus.com/contact/ Hey chaps, hope someone can help with this: I have a PHP form, with a couple of dynamic Select menus, which are populated from two SQL tables: // tbl_main_colour: Code: ID, NAME 1, Red 2, Blue 3, Green // tbl_shade_colour: Code: ID, NAME, FK_MAIN_COLOUR_ID 1, Light Red, 1 2, Dark Red, 1 3, Light Blue, 2 4, Dark Blue, 2 5, Light Green, 3 6, Dark Green, 3 What I'm after is something to filter the second select option, after the first select option has been chosen // Select 1: Code: Red // Select 2: Code: Light Red Dark Red I'm pretty sure this is possible, but not sure how to go about it, any help would be most appreciated. Hey Guys When a user changes the select list called "reason_code_master" I need the uodatecodes() function to update all the other select list with the id of "reason_codes" with the same . How can I do this. <select size='1' onchange="updatecodes()" name='reason_code_master'> <option value='' > - SET REASON - </option> <option value='BROKEN' >BROKEN</option> <option value='ENTERED' >ENTERED</option> <option value='SHORT' >SHORT</option> </select> <select size='1' name='reason_codes' id='reason_codes'> <option value='' > - SET REASON - </option> <option value='BROKEN' >BROKEN</option> <option value='ENTERED' >ENTERED</option> <option value='SHORT' >SHORT</option> </select> <select size='1' name='reason_codes' id='reason_codes'> <option value='' > - SET REASON - </option> <option value='BROKEN' >BROKEN</option> <option value='ENTERED' >ENTERED</option> <option value='SHORT' >SHORT</option> </select> <select size='1' name='reason_codes' id='reason_codes'> <option value='' > - SET REASON - </option> <option value='BROKEN' >BROKEN</option> <option value='ENTERED' >ENTERED</option> <option value='SHORT' >SHORT</option> </select> <select size='1' name='reason_codes' id='reason_codes'> <option value='' > - SET REASON - </option> <option value='BROKEN' >BROKEN</option> <option value='ENTERED' >ENTERED</option> <option value='SHORT' >SHORT</option> </select> Hello, I am trying to make a simple code that has a selection list (with the choice fruit or veggie). When the user chooses fruit, the second list displays the options apple, orange, banana. When the user changes their choice to veggie, the second select list then contains carrot, corn, potatoes (and the apple, orange, banana disappear). I need some advice on how to do this Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <form name = "form1"> <fieldset> <legend>Fruit or Veggie</legend> <select name = "S1"> <option name = "fruit">Fruit </option> <option name = "veggie">Veggie</option> </select> <select name = "S2" </select> </fieldset> </form> <script language="JavaScript" type="text/javascript"> ??? </script> </body> </html> Hi JS Experts, I am working on a class registration system that requires students to register for a main class (101, 102 or 103). The student is supposed to select one main course as well as provide a second choice in case the first is not available. I have two dropdown select fields to capture data 1) Choice -1: 101 / 102 / 103 ( Student needs to select one - Reading the classID from classes table) 2) Choice -2: 101 / 102 / 103 ( If student selects 101 in Choice-1 then the only classes available under Choice-2 should be 102 or 103). How can I accomplish the above? Further to this there are two fields on the form where I would like to auto populate based on what they have selected in Choice-1 and Choice-2. For Example: If a parent selects choice1: 101 the child Choice1 field should autopopulate with 100. If a parent selects Choice2: 201 the child Choice2 field should autopopulate with 200 Any help would be really appreciated. Thanks Vinny I have a select box that has ~7000 options, that based on a different dropdown select & input field, gets filtered to 0 - 300 entries. I have another select dropdown that has 13000+ options in total for all the ~7000 entries, but each entry may have 1 to 5 options of these 13000. Is there a way to change the options of the last select dropdown based on what the user chooses in the filtered select box? Currently the idea I'm having is to have the browser load all 13000+ items and filter out the ones that don't apply to the currently selected item, but I'm not sure what kind of lag the user would experience while the browser loads & filters through all these items. Any help would be appreciated. Thanks. I've got some directory list boxes on the site I'm working on. I made them big and fixed rather than drop-down so they're easier to use in this context. But I had to enable the "multiple" attribute to make that work. The site has no provision for multiple selections so it's a tad annoying when the search function selects more than one name in the list. It doesn't really affect the site's operation but it could be confusing to some people. Is there a way to make the listbox show multiple selections without allowing multiple selections? Thanks for any help. <select onchange="display.apply(this, this.value.split(','))" multiple="multiple" id="People" name="People" style="border-style: none; height:244px; width:220px; margin-bottom: 15px;"> <option>Loading</option> </select> Ok so I'm making this form which when a selection is made in one box it will run through the javascript(function getMgmtHours), and update the div(mgmthours). Then another box shows up allowing another selection to be made which runs through the javascript(function getDays) and updates another div(mgmtdate). My problem is that when I use the second box to run through javascript, it overwrites what shows up in the first div (mgmthours) when it should be updating a different div (mgmtdate). Any ideas what I can do to get it update the relevant div and not overwrite the other one? Here is part of the javascript I have in my page head: Code: function getMgmtHours(str) { if (str=="") { document.getElementById("mgmthours").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("mgmthours").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getmgmthours.php?dist="+str,true); xmlhttp.send(); } function getDays(str) { if (str=="") { document.getElementById("mgmtdate").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("mgmtdate").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getdates.php?sunday="+str,true); xmlhttp.send(); } Here is the HTML/PHP portion being used: PHP Code: echo "<p>"; echo "Submit hours:"; echo "<form>"; echo "<select name='district' onchange='getMgmtHours(this.value)'>"; echo "<option value=''>Select a district:</option> <option value='1'>1</option> <option value='3'>3</option> <option value='4'>4</option>"; echo "</select>"; echo "</form>"; echo "</p>" echo "<p>"; echo "<form action='./hours.php' method='post' onSubmit='return checkMgmtHours'>"; echo "Weekending Day: "; echo "<select name='weekending' onchange='getDays(this.value)'>"; echo "<option value=''>Choose a Date:</option>"; while ($week < 32) { $nextsunday = strtotime("next Sunday"); if ($week > 0) { $timestamp = strtotime("-" . $week . " week", $nextsunday); } else { $timestamp = $nextsunday;} $weekending = date('M. d, Y', $timestamp); echo "<option value='" . $weekending . "'>" . $weekending . "</option>"; $week = $week + 1; } echo "</select>"; echo "<div id='mgmtdate' />"; echo "<div id='mgmthours' />"; echo "</p>"; Edit: Also, after getMgmtHours() runs, I can still use both getDays and getMgmtHours, howeer once I used getDays, I am no longer able to use getMgmtHours w/o refreshing the page. Hi, Been trying to figure this code out for some hours now to no avail. I have 2 radio buttons on the page and would like to get the value from the selected button so I can use it for another function. Code: var alpineResort=document.SkiR.Type.checked=true; var alpineResort=parseFloat(alpineResort) if ( ( document.SkiR.Type[0].checked == false ) && ( document.SkiR.Type[1].checked == false ) ) { alert ( "You have no selected any value." ); valid = false; document.SkiR.Type.focus() } I managed to validate it, but puzzled as to how to get the value out of it. Really need some help as its quite urgent! thanks Im trying to configuere a form that a. a radio buttons that allow the user to choose between quarters, nickels, dimes and pennies. and show image when click on my radio button im confused on how to get the image to display whenthey click on the radio button All, I have the following code: Code: <form action="" name="myform" method="post"> <input type="hidden" id="picimages" name="picimages" value="<?php echo $resultsetstory['bigger_id']; ?>" /> <p> <label> <input type="radio" id="picimages" name="picimages" value="<?php echo $resultsetstory['picture_id']; ?>" /> <?php if($resultsetstory['title']<>""){ echo $resultsetstory['title']; }else{ echo "Image 1"; } ?> </label> <br /> <label> <input type="radio" id="picimages" name="picimages" value="<?php echo $resultsetpic2['picture_id']; ?>" /> <?php if($resultsetpic2['title']<>""){ echo $resultsetpic2['title']; }else{ echo "Image 2"; } ?> </label> <br /> <input name="submit" type="button" value="Vote!" onclick="javascript:voteupdate(this.myform);"/> </p> </form> When I submit this, it goes to this function: Code: function voteupdate(obj) { var poststr = "picimage=" + document.getElementById("picimage").value + "&bigger_id=" + encodeURI( document.getElementById("bigger_id").value ); alert(poststr); makePOSTRequest('voteresults.php', poststr); } However I can't get the value of the radio group for the one that is selected. Can someone see what is wrong? Thanks. Hi, I could not get the radio to work. I need to be able tot select the different radio buttons in which it will produce different rates for calculation. But after reaching here, am not sure what is wrong with the coding as there are no error msgs, and it only uses the 18/0.18 rates, even when 25/0.28 rates are selected. Could someone advise me? Thanks Code as show below- Code: <a name="A"></a> <script language="JavaScript"> function stocks(form) { shares = form.shares.value * 1; buyprice = form.buyprice.value * 1; sellprice = form.sellprice.value * 1; dividends = form.dividends.value * 1; buyoption = form.buyoption.value * 1; selloption = form.selloption.value * 1; //Checking Buy Commission if (buyoption>24) { bco1=25; bco2=0.28; } else { bco1=18; bco2=0.18; } //Checking Sell Commission if (selloption>24) { sco1=25; sco2=0.28; } else { sco1=18; sco2=0.18; } //Calc Buying Cost ba1=shares*buyprice; ba2=bco1; ba3=(shares*buyprice)/100*0.04; ba4=(shares*buyprice)/100*0.0075; ba5=(ba2+ba3+ba4)/100*7; baf=Math.round((ba1+ba2+ba3+ba4+ba5)*100)/100; bb1=shares*buyprice; bb2=(shares*buyprice)/100*bco2; bb3=(shares*buyprice)/100*0.04; bb4=(shares*buyprice)/100*0.0075; bb5=(bb2+bb3+bb4)/100*7; bbf=Math.round((bb1+bb2+bb3+bb4+bb5)*100)/100; //Compare Cost if (baf>bbf) { bc=baf; } else { bc=bbf; } //Calc Selling Cost sa1=shares*sellprice; sa2=sco1; sa3=(shares*sellprice)/100*0.04; sa4=(shares*sellprice)/100*0.0075; sa5=(sa2+sa3+sa4)/100*7; saf=Math.round((sa1-(sa2+sa3+sa4+sa5))*100)/100; sb1=shares*sellprice; sb2=(shares*sellprice)/100*sco2; sb3=(shares*sellprice)/100*0.04; sb4=(shares*sellprice)/100*0.0075; sb5=(sb2+sb3+sb4)/100*7; sbf=Math.round((sb1-(sb2+sb3+sb4+sb5))*100)/100; //Compare Returns if (saf<sbf) { tr=saf; } else { tr=sbf; } //Calc Break Even Price bepwod1=(bc/shares); bepwd1=((bc-dividends)/shares); bepwod=bepwod1.toFixed(3); bepwd=bepwd1.toFixed(3); //Calc Profit and Loss plwod1=tr-bc; plwd1=tr+dividends-bc; plwod=plwod1.toFixed(3); plwd=plwd1.toFixed(3); //Returning Values bought = bc; // Total Cost sold = tr; // Total Returns form.buycost.value = "$ " + bought; form.sellcost.value = "$ " + sold; form.breakevenpricewod.value = "$ " + bepwod; form.breakevenpricewd.value = "$ " + bepwd; form.profitlosswod.value = "$ " + plwod; form.profitlosswd.value = "$ " + plwd; } </script> <center> <form name='stockform'> <table border=0> <tr> <td align=left>* No. of Shares</td> <td>:</td> <td><input type="text" name="shares" /></td> <td align=left>Total Cost</td> <td>:</td> <td><input type="text" readonly="readonly" name="buycost" /></td> </tr> <tr> <td align=left>* Buying Price</td> <td>:</td> <td><input type="text" name="buyprice" /></td> <td align=left>Total Returns</td> <td>:</td> <td><input type="text" readonly="readonly" name="sellcost" /></td> </tr> <tr> <td align=left>* Selling Price</td> <td>:</td> <td><input type="text" name="sellprice" /></td> <td align=left>Break Even Price w/o Dividends</td> <td>:</td> <td><input type="text" readonly="readonly" name="breakevenpricewod" /></td> </tr> <tr> <td align=left>* Dividends</td> <td>:</td> <td><input type="text" name="dividends" /></td> <td align=left>Break Even Price w Dividends</td> <td>:</td> <td><input type="text" readonly="readonly" name="breakevenpricewd" /></td> </tr> <tr> <td align=left>Buy @ Commission</td> <td>:</td> <td><input type="radio" name="buyoption" value="18" checked>$18/0.18%<br> <input type="radio" name="buyoption" value="25">$25/0.28%<br></td> <td align=left>Profit & Loss w/o Dividends</td> <td>:</td> <td><input type="text" readonly="readonly" name="profitlosswod" /></td> </tr> <tr> <td align=left>Sell @ Commission</td> <td>:</td> <td><input type="radio" name="selloption" value="18">$18/0.18%<br> <input type="radio" name="selloption" value="25" checked>$25/0.28%<br></td> <td align=left>Profit & Loss w Dividends</td> <td>:</td> <td><input type="text" readonly="readonly" name="profitlosswd" /></td> </tr> <tr> <td colspan=3 align=center> <input type="button" name="calc" value="Calculate" onclick="javascript:stocks(this.form)" /> </td> <td align=left></td> <td></td> <td></td> </tr> </table> </form> </center> I have an assignment do tomorrow and the program worked then i saved turned it off and today it don't plz help oh and im not that good so try to be simple :P Code: <html> <head> <script type="text/javascript"> //Egon Klein //W0637104 //MIT153 function calculate() { //Cm - Cm var INPUT = document.getElementById("input"); if (CM1.checked && CM2.checked) {document.write(INPUT.value)} //Km - Km var INPUT = document.getElementById("input"); if (KM1.checked && KM2.checked) {document.write(INPUT.value)} //Meters - Meters var INPUT = document.getElementById("input"); if (METERS1.checked && METERS2.checked) {document.write(INPUT.value)} //Cm - Meters var INPUT = document.getElementById("input"); if (CM1.checked && METERS2.checked) {document.write(INPUT.value/100)} // Cm - Km var INPUT = document.getElementById("input"); if (CM1.checked && KM2.checked) {document.write(INPUT.value/100000)} //Meters - Cm var INPUT = document.getElementById("input"); if (METERS1.checked && CM2.checked) {document.write(INPUT.value*100)} //Meters - Km var INPUT = document.getElementById("input"); if (METERS1.checked && KM2.checked) {document.write(INPUT.value/1000)} //Km - Cm var INPUT = document.getElementById("input"); if (KM1.checked && CM2.checked) {document.write(INPUT.value*100000)} //Km - Meters var INPUT = document.getElementById("input"); if (KM1.checked && METERS2.checked) {document.write(INPUT.value*1000)} // Cm - Inches var INPUT = document.getElementById("input"); if (CM1.checked && INCHES2.checked) {document.write(INPUT.value*0.393700787)} /////////////////////////////////////////////////////////////// //Km - Inches var INPUT = document.getElementById("input"); if (KM1.checked && INCHES2.checked) {document.write(INPUT.value*39 370.0787)} //Meters - Inches var INPUT = document.getElementById("input"); if (METERS1.checked && INCHES2.checked) {document.write(INPUT.value*39.3700787)} //Cm - Feet var INPUT = document.getElementById("input"); if (CM1.checked && FEET2.checked) {document.write(INPUT.value*0.032808399)} //Km - Feet var INPUT = document.getElementById("input"); if (KM1.checked && FEET2.checked) {document.write(INPUT.value*3280.8399)} //Meters - Feet var INPUT = document.getElementById("input"); if (METERS1.checked && FEET2.checked) {document.write(INPUT.value*3.2808399)} //Cm - Yard var INPUT = document.getElementById("input"); if (CM1.checked && YARD2.checked) {document.write(INPUT.value*0.010936133)} //Km - Yard var INPUT = document.getElementById("input"); if (KM1.checked && YARD2.checked) {document.write(INPUT.value*1 093.6133)} //Meters - Yard var INPUT = document.getElementById("input"); if (METERS1.checked && YARD2.checked) {document.write(INPUT.value*1.0936133)} //Cm - Miles var INPUT = document.getElementById("input"); if (CM1.checked && MILES2.checked) {document.write(INPUT.value*0.000006213712)} //Km - Miles var INPUT = document.getElementById("input"); if (KM1.checked && MILES2.checked) {document.write(INPUT.value*0.621371192)} //Meters - Miles var INPUT = document.getElementById("input"); if (METERS1.checked && MILES2.checked) {document.write(INPUT.value*0.000621371192)} //Inches - Cm var INPUT = document.getElementById("input"); if (INCHES1.checked && CM2.checked) {document.write(INPUT.value*2.54)} //Inches - Km var INPUT = document.getElementById("input"); if (INCHES1.checked && KM2.checked) {document.write(INPUT.value*0.0000254)} //Inches - Meters var INPUT = document.getElementById("input"); if (INCHES1.checked && METERS2.checked) {document.write(INPUT.value*0.0254)} //Feet - Cm var INPUT = document.getElementById("input"); if (FEET1.checked && CM2.checked) {document.write(INPUT.value*30.48)} //Feet - Km var INPUT = document.getElementById("input"); if (FEET1.checked && KM2.checked) {document.write(INPUT.value*0.0003048)} //Feet - Meters var INPUT = document.getElementById("input"); if (FEET1.checked && METERS2.checked) {document.write(INPUT.value*0.3048)} //Yard - Cm var INPUT = document.getElementById("input"); if (YARD1.checked && CM2.checked) {document.write(INPUT.value*91.44)} //Yard - Km var INPUT = document.getElementById("input"); if (YARD1.checked && KM2.checked) {document.write(INPUT.value*0.0009144)} //Yard - Meters var INPUT = document.getElementById("input"); if (YARD1.checked && METERS2.checked) {document.write(INPUT.value*0.9144)} //Miles - Cm var INPUT = document.getElementById("input"); if (MILES1.checked && CM2.checked) {document.write(INPUT.value*160 934.4)} //Miles - Km var INPUT = document.getElementById("input"); if (MILES1.checked && KM2.checked) {document.write(INPUT.value*1.609344)} //Miles - Meters var INPUT = document.getElementById("input"); if (MILES1.checked && METERS2.checked) {document.write(INPUT.value*1609.344)} //Inches - Inches var INPUT = document.getElementById("input"); if (INCHES1.checked && INCHES2.checked) {document.write(INPUT.value)} //Inches - Feet var INPUT = document.getElementById("input"); if (INCHES1.checked && FEET2.checked) {document.write(INPUT.value*0.0833333333)} //Inches - Yard var INPUT = document.getElementById("input"); if (INCHES1.checked && YARD2.checked) {document.write(INPUT.value*0.0277777778)} //Inches - Miles var INPUT = document.getElementById("input"); if (MILES1.checked && MILES2.checked) {document.write(INPUT.value*0.0000157828283)} //Feet - Feet var INPUT = document.getElementById("input"); if (FEET1.checked && FEET2.checked) {document.write(INPUT.value)} //Feet - Inches var INPUT = document.getElementById("input"); if (FEET1.checked && INCHES2.checked) {document.write(INPUT.value*12)} //Feet - Yard var INPUT = document.getElementById("input"); if (FEET1.checked && YARD2.checked) {document.write(INPUT.value*0.33333333)} //Feet - Miles var INPUT = document.getElementById("input"); if (FEET1.checked && MILES2.checked) {document.write(INPUT.value*0.000189393939)} //Yard - Yard var INPUT = document.getElementById("input"); if (YARD1.checked && YARD2.checked) {document.write(INPUT.value)} //Yard - Feet var INPUT = document.getElementById("input"); if (YARD1.checked && FEET2.checked) {document.write(INPUT.value*3)} //Yard - Inches var INPUT = document.getElementById("input"); if (YARD1.checked && INCHES2.checked) {document.write(INPUT.value*36)} //Yard - Miles var INPUT = document.getElementById("input"); if (YARD1.checked && MILES2.checked) {document.write(INPUT.value*0.000568181818)} //Miles - Miles var INPUT = document.getElementById("input"); if (MILES1.checked && MILES2.checked) {document.write(INPUT.value)} //Miles - Inches var INPUT = document.getElementById("input"); if (MILES1.checked && INCHES2.checked) {document.write(INPUT.value*63 360)} //Miles - Feet var INPUT = document.getElementById("input"); if (MILES1.checked && FEET2.checked) {document.write(INPUT.value*5280)} //Miles - Yard var INPUT = document.getElementById("input"); if (MILES1.checked && YARD2.checked) {document.write(INPUT.value*1760)} } </script> </head> <body> <form> <h4>Input Measurement:</h4> <input type="text" id="input"/> <input type="radio" name="Type1" id="CM1" checked="true"/>Cm <input type="radio" name="Type1" id="KM1" checked="true"/>Km <input type="radio" name="Type1" id="METERS1" checked="true"/>Meters <input type="radio" name="Type1" id="INCHES1" checked="true"/>Inches <input type="radio" name="Type1" id="FEET1" checked="true"/>Feet <input type="radio" name="Type1" id="YARD1" checked="true"/>Yard <input type="radio" name="Type1" id="MILES1" checked="true"/>Miles <h4>Conversion Measurement:</h4> <input type="radio" name="Type2" id="CM2" checked="true"/>Cm <br/> <input type="radio" name="Type2" id="KM2" checked="true"/>Km <br/> <input type="radio" name="Type2" id="METERS2" checked="true"/>Meters <br/> <input type="radio" name="Type2" id="INCHES2" checked="true"/>Inches <br/> <input type="radio" name="Type2" id="FEET2" checked="true"/>Feet <br/> <input type="radio" name="Type2" id="YARD2" checked="true"/>Yard <br/> <input type="radio" name="Type2" id="MILES2" checked="true"/>Miles <br/> <input type="button" onclick="calculate()" value="Calculate"/> </form> </body> </html> Thanks for clicking on this to possibly help me. I've been trying for hours to get my page to do one calculations when a radio is clicked... or to do another if a different radio is clicked. any help would be GREATLY appreciated. here is a simplified version of the code (it'd be pointless to give you the whole code, it's way too big.) Code: <html> <head> <title>This doesn't work...</title> </head> <body> <script type="text/javascript"> function doit(){ var firstnum = form.num1.value - form.num2.value; var secondnum = form.num1.value + form.num2.value; if (form.op1.checked){ form.results.value = firstnum; } if (form.op2.checked){ form.results.value = secondnum; } } </script> <form name="form" method="post"> Num 1: <input type="text" name="num1" /><br /> Num 2: <input type="text" name="num2" /><br /> Option One <input type="radio" name="op1" /><br /> Option Two <input type="radio" name="op2" /><br /> <input type="submit" onClick="doit" /><br /> Results: <input type="text" name="results" /><br /> </form> </body> </html> I'm creating a unit converter program using radio buttons and i can't seem to get one aspect working. i can't seem to get another set of radio buttons to display. the way the program is supposed to work is there will be 3 radio buttons saying to convert length, weight, and volume. if the user selects to convert weight, another set of radio buttons will appear with 2 options, to convert from pounds to kilograms, or kilograms to pounds. then the user enters the number in a text box and clicks to convert button. my problem is getting the second set of radio buttons to display. I have no clue how to get this to work. to get a better understanding of whats going on, here is the program without the radio buttons that i created. i'm trying to use radio buttons in place of the prompting message. Code: <!DOCTYPE html> <html> <head> <title> Conversions of Weight and Length</title> <script type="text/javascript"> function clearMe() { var _s=top; var _d=_s.document; _d.open(); _d.write(""); _d.close(); } function main() { var repeat = confirm("Do you want to perform another conversion ? \r" + "<p><b>Note:</b> Pressing OK allows for another conversion, and pressing CANCEL exits</p>"); if(repeat==true) { convert(); } else { alert("Your program has been terminated!"); self.close(); } } function convert() { var unit, direction, value, result, original_units, new_units; document.write("<br/><br/>") document.write("Weight and Length conversion menu" + "<br/><br/>"); document.write("1. convert length" + "<br />"); document.write("2. convert weight" + "<br />"); document.write("3. convert volume" + "<br />"); unit = window.prompt("select conversion type: "); if ((unit<0) || (unit>3)) { alert("Select Menu option 1, 2, or 3!"); unit = window.prompt("Select conversion type: "); } switch (unit) { case '1': direction = choose_direction("<br /><br />1. Feet to meters<br />" , "2. Meters to feet <br />"); if (direction =='1') { original_units = "meters"; new_units = "meters"; } else { new_units = "feet"; original_units = "meters"; } break; case '2': direction = choose_direction("<br /><br />1. Pounds to kilograms <br />", "2. Kilograms to pounds <br /> <br />"); if (direction =='1') { original_units = "pounds"; new_units = "kilograms"; } else { new_units = "pounds"; original_units = "kilograms"; } break; case '3': direction = choose_direction("<br /><br />1. Gallons to liters<br />", "2. Liters to gallons <br /><br />"); if (direction =='1') { original_units = "gallons"; new_units = "liters"; } else { new_units = "gallons"; original_units = "liters"; } break; } value = window.prompt("Enter value to be converted:") switch(unit) { case '1': result = feet_meters(value, direction); break; case '2': result = pounds_kilograms(value, direction); break; case '3': result = gallons_liters(value, direction); break; } document.write(value + original_units + " = " + result + new_units); } function choose_direction(option1, option2) { var direction; document.write(option1); document.write(option2); do { window.prompt("Select a conversion direction"); return direction; } while ((direction!='1') || (direction !='2')); } function pounds_kilograms(value, direction) { if (direction == '1') return parseFloat(value)/parseFloat(2.2046); else return parseFloat(value)*parseFloat(2.2046); } function gallons_liters(value, direction) { if (direction == '1') return parseFloat(value)*parseFloat(3.7854); else return parseFloat(value)/parseFloat(3.7854); } function feet_meters(value, direction) { if (direction == '1') return parseFloat(value)/parseFloat(3.2808); else return parseFloat(value)*parseFloat(3.2808); } </script> </head> <body> <h1> weight and length conversion </h1> <script type="text/javascript"> convert(); main(); </script> </body> </html> Hi I was helped to find the example below to show which presenter is on air now to be displayed on my website. At the moment this displays: DJ Name DJ Photo What I would like it to display is: DJ Name DJ Description DJ Photo Can anyone tell me how to achieve this? Code: function display() { var show = "No show scheduled at present"; var GMToffset = -0; // Your current GMT offset, whether Standard or Daylight var now = new Date(); var dy = now.getDay(); // day of week 0-6 now.setHours(GMToffset + now.getHours() + now.getTimezoneOffset() / 60); var hh = now.getHours(); var mn = now.getMinutes(); hh = hh + (mn/60); // minutes expressed as fractions of an hour // The GMT offset ensures that every visitor, regardless of their timezone, will see the schedule // that is appropriate for the site owner's local time. // Tip - for testing purposes you can put here //dy = 5; //hh = 9.25; // or whatever to check that the right show appears at that day/time. if (dy >=1 && dy <=4) { // days in Javascript are 0 Sunday - 6 Saturday if (hh >=0 && hh <7) {show = "DJ0"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=7 && hh <11) {show = "DJ1"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=11 && hh <14) {show = "DJ2"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=14 && hh <19) {show = "DJ3"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=19 && hh <22) {show = "DJ0"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=22 && hh <=23) {show = "DJ0"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} } if (dy == 5) { if (hh >=0 && hh <7) {show = "DJ0"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=7 && hh <11) {show = "DJ1"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=11 && hh <14) {show = "DJ2"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=14 && hh <19) {show = "DJ3"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=19 && hh <=23) {show = "DJ0"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} } if (dy == 6) { // Saturday Note the two = signs to mean equals if (hh >=0 && hh <8) {show = "DJ0"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=8 && hh <12) {show = "DJ3"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=12 && hh <14) {show = "DJ2"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=14 && hh <18) {show = "DJ4"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=18 && hh <20) {show = "DJ5"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=20 && hh <=23) {show = "DJ0"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} } //End of Saturday Shows if (dy == 0) { //Sunday Shows if (hh >=0 && hh <8) {show = "DJ0"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=8 && hh <12) {show = "DJ4"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=12 && hh <16) {show = "DJ6"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=16 && hh <19) {show = "DJ7"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=19 && hh <22) {show = "DJ7"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} if (hh >=22 && hh <=23) {show = "DJ0"; document.getElementById("theImage").src = "3trfm_template/presenters/xxx.png"} } // End of Sunday Shows var a = "" + show + " \u00A0 \u00A0 \u00A0 \u00A0 "; // spaces must be separted by Unicode spaces to prevent collapse document.getElementById("dj").innerHTML = a; setTimeout("display()", 60000); // update every 60 seconds } |