Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old April 25th, 2008, 12:51 PM   #1
New Member
 

Join Date: Feb 2008
Location: England
Age: 22
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 psycho wolvesbane is on a distinguished road
Table Hide function error

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:

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:

Code:
<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.
psycho wolvesbane is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old April 25th, 2008, 06:49 PM   #2
New Member
 

Join Date: Feb 2008
Location: England
Age: 22
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 psycho wolvesbane is on a distinguished road
Re: Table Hide function error

Edit: Solved by self
psycho wolvesbane is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript show/hide function danny322 JavaScript 1 May 15th, 2008 08:46 AM
multiple table data retrieval with function Wheatus7 Databases 0 June 26th, 2007 09:01 AM
Fatal error: call to a member function funtion() on a non-object timcallagy Databases 2 March 4th, 2007 05:55 PM
Fatal error: Call to a member function getName() on a non-object jono PHP 1 April 13th, 2006 02:53 PM
Having trouble with scripts. Fatal error: Call to undefined function: imagegif() cargi PHP 5 January 6th, 2006 02:59 PM


Search Engine Optimization by vBSEO 3.2.0 RC8