i throw a string value from the database in an input box...when i click update button, i need to clear the textbox after clicking update button..how?thanks a lot...

<form onsubmit='document.getElementById("textbox").value="";'>
<!-- or -->
<input type='submit' onclick='document.getElementById("textbox").value="";'>

or any other combination of form/input & onanything

Use some javascript?

// Make sure input as an ID
// e.g. <input type="text" id="message">
// put this in Javascript in for when the user has submitted the form

<script type="text/javascript">
input = document.getElementById('message');
input.value="";
</script>

post your code here.. It'll be more helpful to solve your problem

i tried some of the codes above but i cant get it still...the purpose is to update the record...after clicking update the value of the "uname" textbox will be deleted...the values was taken from the datatabase....

below is my code..

<?php
$server = 'localhost';
$user = 'root';
$password = '';
$database = 'studentaccount';
$con = mysql_connect ($server,$user,$password);
$db = mysql_select_db($database);
 if (!$db || !$con)
 {
     die ('<h3>SERVER DOWN BE BACK LATER</h3>');
 }
 else
     {
     $user_id=$_GET['user_id'];
     $query = "SELECT * FROM users WHERE user_id=$user_id";
     $result = mysql_query($query);
     $records = mysql_fetch_array($result);
     //$cur_prev = $records ['previledge'];
     //echo $user_id;


     if (isset($_POST['update']))
     {
            $uname = strtoupper($_POST ['uname']);
            $prev = strtoupper($_POST ['prev']);
            $user = md5($_POST ['user']);
            $pass = md5($_POST ['pass']);
            $date = date("Y-m-d");
            $repeatpass = md5($_POST ['repeatpass']);
           // echo "$uname/$prev/$pass/$date/$repeatpass";
            $user_box = $_POST ['user'];
            $pass_box = $_POST ['pass'];
            $repeat_box = ($_POST ['repeatpass']);

            $query = "UPDATE users 
                      SET name='$uname',
                        previledge ='$prev',
                        password = '$pass',
                        date = '$date'
                      WHERE user_id = '$user_id';";

            if (($user_box)=='' || ($pass_box)=='' || ($repeat_box)=='')
            {
            echo "ALL FIELDS ARE REQUIRED!";
            }
            else if(($pass)!= ($repeatpass))
            {
            echo "PASSWORD MISMATCH";
            }   
            else 
            {    
              $result = mysql_query($query);
              if ($result)
              {
                  echo "SUCCESSFULLY SAVED!";
              }
              else
              {

                  echo "SAVE FAILED";
              }   
            }
     } 
      if (isset($_POST['delete']))
      {


          $query = "DELETE FROM users
                    WHERE user_id = '$user_id'";
          $result = mysql_query($query);


          if ($result)
          {
              echo "Successfully Deleted!";
          }
          else
          {
              echo "Delete Failed!";
          }

     }
 }
 ?>



<form method="POST" action="" >
    <table align="center">
            <tr>
            <td>Name:</td>
            <td><input type="text" name="uname" value="<?php echo$records['name'];?>"></td>
        </tr>
        <tr>
            <td>Previledge:</td>
            <td>
                <?php
                 $query = "SELECT * FROM previledges";
                $result = mysql_query($query);
                echo "<select name='prev'>";
                while($records = mysql_fetch_array($result))
                {
                  echo "<option>{$records ['prev_desc']}</option>";
                }
                   echo "</select>";
                ?>
                </td>
        </tr>
        <tr>
            <td>Username</td>
            <td><input type="text" name="user" ></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password" name="pass"></td>
        </tr>
         <tr>
            <td>Repeat Password</td>
            <td><input type="password" name="repeatpass"></td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" name="update" value="Update" ><input type="submit" name="delete" value="Delete"></td>

        </tr>
    </table>

</form>

Try this, there is probably an easier way to just attach a function and onclick to your submit but try that :)

<?php
$server = 'localhost';
$user = 'root';
$password = '';
$database = 'studentaccount';
$con = mysql_connect ($server,$user,$password);
$db = mysql_select_db($database);
if (!$db || !$con)
{
die ('<h3>SERVER DOWN BE BACK LATER</h3>');
}
else
{
$user_id=$_GET['user_id'];
$query = "SELECT * FROM users WHERE user_id=$user_id";
$result = mysql_query($query);
$records = mysql_fetch_array($result);
//$cur_prev = $records ['previledge'];
//echo $user_id;


if (isset($_POST['update']))
{
?>
<script type="text/javascript">
var input = document.getElementById('user');
input.value="";
</script>
<?
$uname = strtoupper($_POST ['uname']);
$prev = strtoupper($_POST ['prev']);
$user = md5($_POST ['user']);
$pass = md5($_POST ['pass']);
$date = date("Y-m-d");
$repeatpass = md5($_POST ['repeatpass']);
// echo "$uname/$prev/$pass/$date/$repeatpass";
$user_box = $_POST ['user'];
$pass_box = $_POST ['pass'];
$repeat_box = ($_POST ['repeatpass']);

$query = "UPDATE users 
SET name='$uname',
previledge ='$prev',
password = '$pass',
date = '$date'
WHERE user_id = '$user_id';";

if (($user_box)=='' || ($pass_box)=='' || ($repeat_box)=='')
{
echo "ALL FIELDS ARE REQUIRED!";
}
else if(($pass)!= ($repeatpass))
{
echo "PASSWORD MISMATCH";
} 
else 
{ 
$result = mysql_query($query);
if ($result)
{
echo "SUCCESSFULLY SAVED!";
}
else
{

echo "SAVE FAILED";
} 
}
} 
if (isset($_POST['delete']))
{


$query = "DELETE FROM users
WHERE user_id = '$user_id'";
$result = mysql_query($query);


if ($result)
{
echo "Successfully Deleted!";
}
else
{
echo "Delete Failed!";
}

}
}
?>



<form method="POST" action="" >
<table align="center">
<tr>
<td>Name:</td>
<td><input type="text" name="uname" value="<?php echo$records['name'];?>"></td>
</tr>
<tr>
<td>Previledge:</td>
<td>
<?php
$query = "SELECT * FROM previledges";
$result = mysql_query($query);
echo "<select name='prev'>";
while($records = mysql_fetch_array($result))
{
echo "<option>{$records ['prev_desc']}</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="user" ></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td>Repeat Password</td>
<td><input type="password" name="repeatpass"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="update" value="Update" ><input type="submit" name="delete" value="Delete"></td>

</tr>
</table>

</form>

<td><input type="text" name="uname" value="<?php if(!$_post){echo $records['name'];} ?>"></td>

problem solved! thanks a lot...:) More power..God Bless!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.