Morning, I have a PHP page where I was asked to divide a simple pull down menu into a series of radio buttons and pull down menu for detail. Problem 1: If "Newspaper" is selected (which is the first radio button), the pull down menu will be active and let you select the specific newspaper. If any radio button except "Newspaper" is chosen then the pull down menu should be grayed out and not be able to be used. Right now, it is active all the time. How do I turn off the pull down when the "Newspaper" radio button is not selected? Problem 2: If the newspaper radio button and a specific newspaper is selected in the pull down (Ex: nationalpost) this value is written into the database field (source_type) properly. If any other radio buttons are clicked nothing appears in the source_type database field. I need the value of the selected radio button or newspaper value written to this field. What am I missing? Code appended below. Thanks. <label><b>Where did you FIRST learn about our program(s)</b></label><br> <label><i>Please take the time to fill out this important information as accurately as possible</i></label> <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td>Newspaper Ad<input name="" type="radio" value="newspaper" onclick="test(0);"></td> <td>Another Website<input name="r1" type="radio" value="otherwebsite" onclick="test(1);"></td> <td>Basic Internet Search<input name="r2" type="radio" value="netsearch" onclick="test(2);"></td> <td>AllPsychologySchools.com<input name="r3" type="radio" value="psyschool" onclick="test(3);"></td> <td>Friend, Colleague, Personal referral<input name="r4" type="radio" value="referral" onclick="test(4);"></td> </tr> <tr> <td><label><b>Newspaper Source</b></label><br> <select name="source_type"> <option value="" selected>-- Please Choose --</option> <option value="globeandmail">Globe and Mail</option> <option value="nationalpost">National Post</option> <option value="metronews">Metro News</option> <option value="torontosun">Toronto Sun</option> <option value="24hours">24 Hours</option> <option value="calgaryherald">Calgary Herald</option> <option value="edmontonjournal">Edmonton Journal</option> <option value="vancouversun">Vancouver Sun</option> <option value="mcleansmagazine">McLean's Magazine</option> <option value="telegraphjournal">Telegraph Journal</option> <option value="saskatoonstarpheonix">Saskatoon Star Phoenix</option> <option value="winnipegfreepress">Winnipeg ree Press</option> </select> </td> </tr> </tbody> </table>
OK, I got the pull down menu to shut off correctly with JS. Thanks! Now I just need to solve the database posting issue.
The first part of this form, where it asks for a name and password works fine. If I select a specific newspaper it is posted into the table properly too. It is just the radio buttons that do not get their info posted. Frustrating... Here is the amended code with Javascript: <SCRIPT LANGUAGE=javascript> <!-- function test(choice) { if(choice == 0) { if (document.admission.r1[choice].checked) document.admission.m1.disabled=false; } else { if (document.admission.r1[choice].checked) document.admission.m1.disabled=true; } } //--> </SCRIPT> <p align="center" class="alert"><a href="<?= $_SERVER['PHP_SELF'] ?>?page=home"><b>>> Existing Applicants Click Here <<</b></a></p> <h2>Start a New Application</h2> <form name="admission" method="POST"> <?php if (app_form_errors()) { ?> <div class="form-error"> <strong>Your form was not accepted: </strong> <ol class="form-error"><?php foreach (app_form_errors() as $err) { ?><li><?= $err ?></li><?php } ?></ol></div><?php } ?> <fieldset> <label>Program</label><br> <?php echo HTML_FormTools::selector('program_code',array_merge(array('' => '-- Please Choose --'),myapplication_programs()),rvar('program_code')); ?> </fieldset><BR> <fieldset> <label>Last Name</label><BR><input type="text" name="name_family" size="40" value="<?= fvar('name_family') ?>"/><BR> <label>First Name</label><BR><input type="text" name="name_given" size="40" value="<?= fvar('name_given') ?>"/><br> <label>Email Address</label><BR> <input type="text" name="email" size="40" value="<?= fvar('email') ?>"/> </fieldset><BR> <fieldset> <label>Choose a password</label><BR> <input type="password" name="pw" size="20" value="<?= fvar('pw') ?>" /> <br> <label>Enter the same password again to confirm it</label> <br> <input type="password" name="pw2" size="20" value="<?= fvar('pw2') ?>"/> </fieldset><BR> <fieldset> <label><b>Where did you FIRST learn about our program(s)</b></label><br> <label><i>Please take the time to fill out this important information as accurately as possible</i></label> <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td>Newspaper Ad<input name="r1" type="radio" value="newspaper" onclick="test(0);"></td> <td>Another Website<input name="r1" type="radio" value="otherwebsite" onclick="test(1);"></td> <td>Basic Internet Search<input name="r1" type="radio" value="netsearch" onclick="test(2);"></td> <td>AllPsychologySchools.com<input name="r1" type="radio" value="psyschool" onclick="test(3);"></td> <td>Friend, Colleague, Personal referral<input name="r1" type="radio" value="referral" onclick="test(4);"></td> </tr> <tr> <td><label><b>Newspaper Source</b></label><br> <select name="m1"> <option value="" selected>-- Please Choose --</option> <option value="globeandmail">Globe and Mail</option> <option value="nationalpost">National Post</option> <option value="metronews">Metro News</option> <option value="torontosun">Toronto Sun</option> <option value="24hours">24 Hours</option> <option value="calgaryherald">Calgary Herald</option> <option value="edmontonjournal">Edmonton Journal</option> <option value="vancouversun">Vancouver Sun</option> <option value="mcleansmagazine">McLean's Magazine</option> <option value="telegraphjournal">Telegraph Journal</option> <option value="saskatoonstarpheonix">Saskatoon Star Phoenix</option> <option value="winnipegfreepress">Winnipeg Free Press</option> </select> </td> </tr> </tbody> </table> <br> </fieldset> <input type="submit" value="Submit Form" /> </form> </body>