Jump to content

[SOLVED] How to clear the text box value by clicking on reset button


php1

Recommended Posts

Dear all,

 

I have a 4 TEXTBOX , one SUBMIT button and one RESET button on my form.

how to reset the value enterd in text box on clicking the reset button.

 

my text box is filled with value="<?php $_SESSION['from'];?>"

so when I click on my REST button before clicking SUBMIT the value in text box got cleared.

If i click my RESET button after SUBMIT button the value remans there.

 

can i write some php/java script function to set the textbox.value to blank/set $_SESSION['from']="". when i click on  RESET BUTTON.

Link to comment
Share on other sites

If you set a default value the RESET button resets the field to what you set the value too before changing it.

 

For example. You have a text box with "Hello world" as the value. If you change it to "This is not the place" then press the reset button it'll reset it to "Hello world".

 

Oh and about the JavaScript. You could write some JavaScript that resets all fields to null.

 

<script language="javascript">
function clearAll(){
var e = document.getElementsByTagName("textarea");

//Loop through all textareas
for(i = 0; i < e.length; i++){
	e[i].value = "";
}
}
</script>

Link to comment
Share on other sites

thank you for your reply.

the problem is solved.

i gave two submit button with same name and different value  and put this code

 

<?php

if($_POST['btnsubmit'] == "Clear All")

{

$_SESSION['date'] = "";$_POST['date']="";

?>

 

thank u for the help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.