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.

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>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.