psychowolvesbane Posted April 25, 2008 Share Posted April 25, 2008 Hi, I've made a form for my users to edit their personal details once they are registered. This includes a section called NUS and NUS Number (National Union of Students in UK) and every time the user clicks on the NUS check button it hides/unhides the NUS Num section below it. Now what's wrong with it is that if the user has selected NUS it activates the checkbutton and fills out the NUS Number field, but for some reason it stops the check button from being clicked on and using the function again. This produces no errors in my Error Console in Fire Fox and the strange thing is that if the user doesn't have NUS selected prior to this then the check button and function works fine. Here's the function code: function NUSHide(f){ var mode; <?php if($Cont == false) { if($NUS == 1) { ?> document.Edit_Details_Form.NUS.checked = true mode="block"; <?php } else { ?> if(document.Edit_Details_Form.NUS.checked == true) { mode="block"; } else if(document.Edit_Details_Form.NUS.checked == false) { mode="none"; document.Edit_Details_Form.NUSNum.value=""; } <?php } ?> return document.getElementById('NUSHide').style.display=mode; <?php } else { ?> return false; <?php } ?> } and here is the form code with the NUS part at the bottom: <body onLoad="javascript:NUSHide(document.getElementById('NUSHide'));"> <div class="MainContainer"> <?php require('admin/header.inc'); require('menu.inc') ?> <div class="DivMain"> <?php if($Cont==true) { ?> <span class="head2"><?php echo $MsgEdited?></span><br><br> <a href="my_account.php">Back to My Account</a> <?php $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql2 = "SELECT Email FROM UserAccount WHERE UserID='$EditThisUser'"; $rs2 = mysql_query($sql2, $conn)or die('Problem with query: ' . $sql2 . '<br />' . mysql_error()); $row2 = mysql_fetch_array($rs2); $Email = $row2['Email']; mysql_close($conn); $message=""; $message=$message."<html>"; $message=$message."<body>"; $message=$message."<span style=\"font-family:Comic Sans MS; font-size:24pt; text-align:center; background-color:#E61732; color:white; font-weight:bold\">A&WC Clothing Line</span><br>"; $message=$message."This is a confirmation that you changed your account details.<br><br>"; $message=$message."Your new Password is: $NewPass"."<br>"; $message=$message."If you were not the one responsible for changing this password then please contact The Hub immediately and we will try to sort the problem out for you."; $message=$message."</body>"; $message=$message."</html>"; if (mail($UserEmail,"$User - Change Account Details Confirmation - A&WC Clothing Line",$message,"Content-Type:text/html;charset=us-ascii")) { $MsgChange= "Your password has been changed successfully!"; } else { $MsgChange= "Can't send e-mail on this system... Doh!"; die(); } } else { ?> <span class="head2">Edit Account Details Form</span><br> <span class="errmsg">All fields marked with an * are required</span><br> <?php echo $MsgUser; echo $MsgForename; echo $MsgSurname; echo $MsgCampus; echo $MsgCourse; echo $MsgNUSNum; ?> <span id="mySpan1a" class="mySpan1a"><br></span> <span id="mySpan2a" class="mySpan2a"><br></span> <span id="mySpan3a" class="mySpan3a"><br></span> <span id="mySpan4a" class="mySpan4a"><br></span> <span id="mySpan5a" class="mySpan5a"><br></span> <span id="mySpan6a" class="mySpan6a"><br></span> <br> <form method="post" name="Edit_Details_Form" action="edit_details_form.php" onSubmit="return Validate(this);"> <table style="width:auto; position:absolute;"> <table> <tr><td><?php echo $Err1?><span id="mySpan1b" class="mySpan1b"></span><span class="head4">Username:(Max Length 15 chars)</span><span class="errmsg"> *</span></td> <td><label><input type="text" maxlength="15" name="Username" value="<?php echo $User?>"/></label></td></tr> <tr><td><?php echo $Err2?><span id="mySpan2b" class="mySpan2b"></span><span class="head4">Forename:</span><span class="errmsg"> *</span></td> <td><label><input type="text" maxlength="15" name="Forename" value="<?php echo $Forename?>"/></label></td></tr> <tr><td><?php echo $Err3?><span id="mySpan3b" class="mySpan3b"></span><span class="head4">Surname:</span><span class="errmsg"> *</span></td> <td><label><input type="text" maxlength="20" name="Surname" value="<?php echo $Surname?>"/></label></td></tr> <tr><td><?php echo $Err4?><span id="mySpan4b" class="mySpan4b"></span><span class="head4">Campus based at: </span><span class="errmsg"> *</span></td> <td><label><select name="Campus"/><option value="">Please Select a Campus</option> <?php $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT Campus FROM Campus ORDER BY Campus"; $rs = mysql_query($sql, $conn) or die(mysql_error()); while($row = mysql_fetch_array($rs)) { $Camp = $row['Campus']; echo"<option value='$Camp'"; if($Campus == $Camp) {echo"Selected";} echo">$Camp</option>"; } mysql_close($conn); ?> </select></label></td></tr> <tr></tr> <tr><td><?php echo $Err5?><span id="mySpan5b" class="mySpan5b"></span><span class="head4">Course Name:</span><span class="errmsg"> *</span></td> <td><label><input type="text" size="45" name="Course" value="<?php echo $Course?>"/></label></td></tr> <tr></tr> <tr><td><span class="head4">NUS:</span></td> <td><label><input type="checkbox" name="NUS" <?php if($NUSChk == "on"){echo"Checked";}?> id="NUS" onclick="NUSHide(this)"/></label> </td></tr> </table> <table width="564" class="TableHidden" id="NUSHide"> <tr width="340px"><td width="266"><?php echo $Err6?><span id="mySpan6b" class="mySpan6b"></span><span class="head4">NUS Number: (18 Chars)</span></td> <td width="240"><label><input type="text" maxlength="21" name="NUSNum" value="<?php echo $NUSNum?>"/></label></td></tr> </table> <table> <tr><td><label><input type="submit" style="overflow:visible; width:auto" class="buttonS" name="SubmitB" value="Submit" onMouseOver="OverMouse(this)"; onMouseOut="OutMouse(this)"/> </label> </td></tr> </table> </form> <br><br> <a href="my_account.php">Back to My Account</a> <?php } ?> </div> </div> </body> P.S. $Cont is only used after the form has been submitted successfully so I added that to stop the undefined function error. Quote Link to comment Share on other sites More sharing options...
psychowolvesbane Posted April 25, 2008 Author Share Posted April 25, 2008 Edit: Solved by self Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.