SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to use OnBlur

    Hi,

    I have a problem,i want my table(the User Access table) to disappear if i choose the the "ADMIN LEVEL".i have search on google but they do not fit any of my need's can someone help me..

    Thanks.

    Here is my Html code:
    Code HTML4Strict:
    	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    	<html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    		<title>Edit User</title>
    	<link href="css/mystyle.css" rel="stylesheet" type="text/css"/>
    	<script src="jquery\jquery.min.js"></script>
    <script type="text/javascript" src="jquery\jquery.validate.js"></script> 
     
     <script>
      $(document).ready(function(){
     
    	$.validator.addMethod("noSpecialChars", function(value, element) {
    		  return this.optional(element) || /^[a-z0-9\_]+$/i.test(value);
    	  }, "<font size='3' color='#FF0000'>Username must contain only letters, numbers, or underscore.</font>");
     
        $("#edit").validate({
    	  rules: {
    		pass: "required",
    		rpass: {
    		  equalTo: "#pass"
    		},
     
    		fname:"required",
    		lname:"required",
    		email:"required email",
    		dept:"required",
    		userlvl:"required"
    	  }
     
    	});
      });
      </script>
     <style type="text/css">
    body {
     
    font-family: arial; /* you need some backups here */
    font-size: 17px;
     
    }
    </style> 
    </head>
    <body>
    <br/>
    <br/>
    <p>		
    <table BORDERCOLOR="#0B0B0B" border='1' bgcolor="#F5F5FA" width="70%" align='center'  >
    <tr>
    	<td width="100%" align="left" valign="middle">
    		<img src='img/editprofile.png'>
    	</td>
    </tr>
    <tr>
    <td width="100%" align='center' >
    <meta http-equiv='refresh' content='=2;Viewuser.php'/>
    	<table>
    	<form method='post' id='edit' name='edit' action='edituser.php?UserName=Bert' onSubmit="javascript: var x=window.confirm('Do you wan\'t to save this User?');if (!x) return(false);">
    	<tr>
    		<input type='hidden' value=Bert name='uname'>
    		<td align='right'><b>User Name:</b></td>	
    		<td align='left'>Bert</td>
    	</tr>
    	<tr>
    		<td align='right'><b>First Name:</b></td>
    		<td align='left'><input type='text' id='fname' value='Berto' name='fname'></td>
    	</tr>
    	<tr>
    		<td align='right'><b>Last Name:</b></td>
    		<td align='left'><input type='text' id='lname'  value='Bert' name='lname'></td>
    	</tr>	
    	<tr>
    		<td align='right'><b>Email Address:</b></td>
    		<td align='left'><input type='text' size='35' id='email' value='Myemail.com' name='email'></td>
    	</tr>
    	<tr>
    		<td align='right'><b>Department:</b></td>
    		<td align='left'>
    		<select name='dept' tabindex='8'><option >MIS</option><option >Acct</option><option >HR</option></select>		</td>
    	</tr>
    	<tr>
    		<td  align='right'><b>User Level:</b></td>
    		<td align='left'>
    		<select name='ulvl' tabindex='9'><option>User</option><option>Support</option><option>Admin</option></select></td></tr></table><tr><td align='center'><b>User Access</b></td></tr><tr><td><input type='checkbox' name='CreateTicket'>Create Ticket<br><input type='checkbox' name='AddUser' >Add User<br><input type='checkbox' name='EditProfile' >Edit/Delete User<br><input type='checkbox' name='ResetPass'>Reset Password<br><input type='checkbox' name='Department'>Add Department<br><input type='checkbox' name='Category'>Add Category<br><input type='checkbox' name='SubCategory'unchecked>Add Sub-Category</td></tr>	<tr>
    		<td align='center' >
    		<input type='submit' value='Save' name='save' title='Save User'>
    		</td>
    	</tr>
    	</form>
    </td>	
     
     
    </tr>	
    </table>
     
    	</body>
    	</html>

    and this is my php code:
    Code PHP:
    	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    	<html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    		<title>Edit User</title>
    	<link href="css/mystyle.css" rel="stylesheet" type="text/css"/>
    	<script src="jquery\jquery.min.js"></script>
    <script type="text/javascript" src="jquery\jquery.validate.js"></script> 
     
     <script>
      $(document).ready(function(){
     
    	$.validator.addMethod("noSpecialChars", function(value, element) {
    		  return this.optional(element) || /^[a-z0-9\_]+$/i.test(value);
    	  }, "<font size='3' color='#FF0000'>Username must contain only letters, numbers, or underscore.</font>");
     
        $("#edit").validate({
    	  rules: {
    		pass: "required",
    		rpass: {
    		  equalTo: "#pass"
    		},
     
    		fname:"required",
    		lname:"required",
    		email:"required email",
    		dept:"required",
    		userlvl:"required"
    	  }
     
    	});
      });
      </script>
     <style type="text/css">
    body {
     
    font-family: arial; /* you need some backups here */
    font-size: 17px;
     
    }
    </style> 
    </head>
    <body>
    <br/>
    <br/>
    <p>		
    <table BORDERCOLOR="#0B0B0B" border='1' bgcolor="#F5F5FA" width="70%" align='center'  >
    <tr>
    	<td width="100%" align="left" valign="middle">
    		<img src='img/editprofile.png'>
    	</td>
    </tr>
    <tr>
    <td width="100%" align='center' >
    <meta http-equiv='refresh' content='=2;Viewuser.php'/>
    	<table>
    	<form method='post' id='edit' name='edit' action='edituser.php?UserName=Bert' onSubmit="javascript: var x=window.confirm('Do you wan\'t to save this User?');if (!x) return(false);">
    	<tr>
    		<input type='hidden' value=Bert name='uname'>
    		<td align='right'><b>User Name:</b></td>	
    		<td align='left'>Bert</td>
    	</tr>
    	<tr>
    		<td align='right'><b>First Name:</b></td>
    		<td align='left'><input type='text' id='fname' value='Berto' name='fname'></td>
    	</tr>
    	<tr>
    		<td align='right'><b>Last Name:</b></td>
    		<td align='left'><input type='text' id='lname'  value='Bert' name='lname'></td>
    	</tr>	
    	<tr>
    		<td align='right'><b>Email Address:</b></td>
    		<td align='left'><input type='text' size='35' id='email' value='mnl_systech@ph.nykline.com' name='email'></td>
    	</tr>
    	<tr>
    		<td align='right'><b>Department:</b></td>
    		<td align='left'>
    		<select name='dept' tabindex='8'><option >MIS</option><option >Acct</option><option >HR</option></select>		</td>
    	</tr>
    	<tr>
    		<td  align='right'><b>User Level:</b></td>
    		<td align='left'>
    		<select name='ulvl' tabindex='9'><option>User</option><option>Support</option><option>Admin</option></select></td></tr></table><tr><td align='center'><b>User Access</b></td></tr><tr><td><input type='checkbox' name='CreateTicket'>Create Ticket<br><input type='checkbox' name='AddUser' >Add User<br><input type='checkbox' name='EditProfile' >Edit/Delete User<br><input type='checkbox' name='ResetPass'>Reset Password<br><input type='checkbox' name='Department'>Add Department<br><input type='checkbox' name='Category'>Add Category<br><input type='checkbox' name='SubCategory'unchecked>Add Sub-Category</td></tr>	<tr>
    		<td align='center' >
    		<input type='submit' value='Save' name='save' title='Save User'>
    		</td>
    	</tr>
    	</form>
    </td>	
     
     
    </tr>	
    </table>
     
    	</body>
    	</html>

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    I don't see any php code?

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry.

    Here is it.
    Code PHP:
    <?php
    session_start();
    if(isset( $_SESSION['username'])){
    include_once("conn.php");	
    ?>
    	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    	<html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    		<title>Edit User</title>
    	<link href="css/mystyle.css" rel="stylesheet" type="text/css"/>
    	<script src="jquery\jquery.min.js"></script>
    <script type="text/javascript" src="jquery\jquery.validate.js"></script> 
     
     <script>
      $(document).ready(function(){
     
    	$.validator.addMethod("noSpecialChars", function(value, element) {
    		  return this.optional(element) || /^[a-z0-9\_]+$/i.test(value);
    	  }, "<font size='3' color='#FF0000'>Username must contain only letters, numbers, or underscore.</font>");
     
        $("#edit").validate({
    	  rules: {
    		pass: "required",
    		rpass: {
    		  equalTo: "#pass"
    		},
     
    		fname:"required",
    		lname:"required",
    		email:"required email",
    		dept:"required",
    		userlvl:"required"
    	  }
     
    	});
      });
      </script>
     <style type="text/css">
    body {
     
    font-family: arial; /* you need some backups here */
    font-size: 17px;
     
    }
    </style> 
    </head>
    <body>
    <br/>
    <br/>
    <p>		
    <table BORDERCOLOR="#0B0B0B" border='1' bgcolor="#F5F5FA" width="70%" align='center'  >
    <tr>
    	<td width="100%" align="left" valign="middle">
    		<img src='img/editprofile.png'>
    	</td>
    </tr>
    <tr>
    <td width="100%" align='center' >
    <?php
    if(isset($_POST['save'])){
    		//User Access
    		if(isset($_POST['CreateTicket'])){
    		$CreateTicket='1';
    		}else{
    		$CreateTicket='0';
    		}
    		if(isset($_POST['AddUser'])){
    		$AddUser='1';
    		}else{
    		$AddUser='0';
    		}
    		if(isset($_POST['Department'])){
    		$Department='1';
    		}else{
    		$Department='0';
    		}
    		if(isset($_POST['Category'])){
    		$Category='1';
    		}else{
    		$Category='0';
    		}
    		if(isset($_POST['SubCategory'])){
    		$SubCategory='1';
    		}else{
    		$SubCategory='0';
    		}
    		if(isset($_POST['EditProfile'])){
    		$UserEdit='1';
    		}else{
    		$UserEdit='0';
    		}
    		if(isset($_POST['ResetPass'])){
    		$PassReset='1';
    		}else{
    		$PassReset='0';
    		}
    mssql_query("sp_edituser @lname='$_POST[lname]',@fname='$_POST[fname]',@upby='$_SESSION[username]',@uname='$_POST[uname]',@userlevel='$_POST[ulvl]',@email='$_POST[email]',@department='$_POST[dept]',@Cticket='$CreateTicket',@AddUser='$AddUser',@adept='$Department',@acat='$Category',@asubcat='$SubCategory',@edituser='$UserEdit',@pass='$PassReset'");
    	mssql_close($con);
    		echo "<b><p align='center'><font color='#F0000' size='3'>User has been edit.</font></p></b>";
    	}
     
    	$d=mssql_query("Select * from vw_dept");
     
    	$lvl=mssql_query("spvw_userlevel @username='$_GET[UserName]' ");
    	//$lvl=mssql_query("Select UserLevel from tblUser where UserName='$_GET[UserName]'");
    	$row=mssql_fetch_array(mssql_query("spview_edituser @username='$_GET[UserName]'"));
    print "<meta http-equiv='refresh' content='=2;Viewuser.php'/>";	
     
    ?>
     
    	<table>
    	<form method='post' id='edit' name='edit' action='edituser.php?UserName=<?php echo $row['UserName'];?>' onSubmit="javascript: var x=window.confirm('Do you wan\'t to save this User?');if (!x) return(false);">
    	<tr>
    		<input type='hidden' value=<?php echo $row['UserName'];?> name='uname'>
    		<td align='right'><b>User Name:</b></td>	
    		<td align='left'><?php echo $row['UserName'];?></td>
    	</tr>
    	<tr>
    		<td align='right'><b>First Name:</b></td>
    		<td align='left'><input type='text' id='fname' value='<?php  echo $row['Firstname'];?>' name='fname'></td>
    	</tr>
    	<tr>
    		<td align='right'><b>Last Name:</b></td>
    		<td align='left'><input type='text' id='lname'  value='<?php  echo $row['Lastname'];?>' name='lname'></td>
    	</tr>	
    	<tr>
    		<td align='right'><b>Email Address:</b></td>
    		<td align='left'><input type='text' size='35' id='email' value='<?php echo $row['Email'];?>' name='email'></td>
    	</tr>
    	<tr>
    		<td align='right'><b>Department:</b></td>
    		<td align='left'>
    		<?php
     
    			echo "<select name='dept' tabindex='8'>";
    			while($dept=mssql_fetch_array($d)){
    				echo "<option ";
    				if ($row['dept']==$dept['DeptName']) echo "Selected=Selected";
    				echo ">".$dept['DeptName']."</option>";
    			}
    				echo '</select>';
    		?>
    		</td>
    	</tr>
    	<tr>
    		<td  align='right'><b>User Level:</b></td>
    		<td align='left'>
    		<?php 
    			echo "<select name='ulvl' tabindex='9'>";
    			while($level=mssql_fetch_array($lvl)){
    				echo "<option ";
    				if ($row['UserLevel']==$level['UserLevel']) echo "Selected=Selected";
    				echo ">".$level['UserLevel']."</option>";
     
    			}echo "<option>User</option>";
    				echo "<option>Support</option>";
    				echo "<option>Admin</option>";
    				echo '</select>';
     
    		echo "</td>";
    	echo "</tr>";
     
    	echo "</table>";
    		if($UserAccess=mssql_fetch_array(mssql_query("sp_useraccess @username='$_GET[UserName]',@userlevel='Admin'"))){
     
    	echo "<tr>";
    	echo "<td align='center'>";
    	echo "<b>User Access</b>";
    	echo "</td>";
    	echo "</tr>";
    	echo "<tr>";
    		echo "<td>";
    			echo"<input type='checkbox' name='CreateTicket'";  if(trim($UserAccess[CreateTicket])=='1'){echo 'checked';}echo ">Create Ticket<br>";
    			echo "<input type='checkbox' name='AddUser' "; if(trim($UserAccess[AddUser])=='1'){echo 'checked';}echo">Add User<br>";
    			echo "<input type='checkbox' name='EditProfile' ";if(trim($UserAccess[AEditUser])=='1'){echo 'checked';}echo">Edit/Delete User<br>";
    			echo "<input type='checkbox' name='ResetPass'"; if(trim($UserAccess[APass])=='1'){echo 'checked';} echo">Reset Password<br>";
    			echo "<input type='checkbox' name='Department'"; if(trim($UserAccess[ADept])=='1'){echo 'checked';} echo">Add Department<br>";
    			echo "<input type='checkbox' name='Category'";  if(trim($UserAccess[ACat])=='1'){echo 'checked';}echo">Add Category<br>";
    			echo "<input type='checkbox' name='SubCategory'";  if(trim($UserAccess[ASubCat])=='1'){echo 'checked';}else{ echo 'unchecked';}echo">Add Sub-Category";
     
    		echo "</td>";
    	echo "</tr>";
    	}
    	?>
    	<tr>
    		<td align='center' >
    		<input type='submit' value='Save' name='save' title='Save User'>
    		</td>
    	</tr>
    	</form>
    </td>	
     
     
    </tr>	
    </table>
     
    	</body>
    	</html>
    <?php
    }else{ //not logged in
        header('location: login.php');
    }
    ?>

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,863
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You keep posting HTML instead of PHP. What you are asking to do needs to be done in the PHP and not in the JavaScript.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'am not sure what you mean i keep posting HTML.

    this is the page where it can edit the user level.
    my question is how can i disable the second table if choose the Admin level in the select tag..When i lost my focus on the Select tag
    Code PHP:
    <?php
    echo"<table>";
    echo"<tr>";
           echo " <td  align='right'><b>User Level:</b></td>";
            <td align='left'>
     
             \\this is where to check echo my user level
                echo "<select name='ulvl' tabindex='9'>";
                while($level=mssql_fetch_array($lvl)){
                    echo "<option ";
                    if ($row['UserLevel']==$level['UserLevel']) echo "Selected=Selected";
                    echo ">".$level['UserLevel']."</option>";
                  \\this is where i will choose to edit my user level
                }echo "<option>User</option>";
                    echo "<option>Support</option>";
                    echo "<option>Admin</option>";
                    echo '</select>';
     
            echo "</td>";
    echo  "</tr>";
    echo </table>";
    \\if the login user is admin it can edit the none admin level
    \\second table
    echo "<table>";
        if($UserAccess=mssql_fetch_array(mssql_query("sp_useraccess @username='$_GET[UserName]',@userlevel='Admin'"))){
     
        echo "<tr>";
        echo "<td align='center'>";
        echo "<b>User Access</b>";
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
            echo "<td>";
                echo"<input type='checkbox' name='CreateTicket'";  if(trim($UserAccess[CreateTicket])=='1'){echo 'checked';}echo ">Create Ticket<br>";
                echo "<input type='checkbox' name='AddUser' "; if(trim($UserAccess[AddUser])=='1'){echo 'checked';}echo">Add User<br>";
                echo "<input type='checkbox' name='EditProfile' ";if(trim($UserAccess[AEditUser])=='1'){echo 'checked';}echo">Edit/Delete User<br>";
                echo "<input type='checkbox' name='ResetPass'"; if(trim($UserAccess[APass])=='1'){echo 'checked';} echo">Reset Password<br>";
                echo "<input type='checkbox' name='Department'"; if(trim($UserAccess[ADept])=='1'){echo 'checked';} echo">Add Department<br>";
                echo "<input type='checkbox' name='Category'";  if(trim($UserAccess[ACat])=='1'){echo 'checked';}echo">Add Category<br>";
                echo "<input type='checkbox' name='SubCategory'";  if(trim($UserAccess[ASubCat])=='1'){echo 'checked';}else{ echo 'unchecked';}echo">Add Sub-Category";
     
            echo "</td>";
        echo "</tr>";
        } 
    echo "</table>";
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •