php1 Posted August 29, 2008 Share Posted August 29, 2008 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 https://forums.phpfreaks.com/topic/121827-solved-how-to-clear-the-text-box-value-by-clicking-on-reset-button/ Share on other sites More sharing options...
JasonLewis Posted August 29, 2008 Share Posted August 29, 2008 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 https://forums.phpfreaks.com/topic/121827-solved-how-to-clear-the-text-box-value-by-clicking-on-reset-button/#findComment-628535 Share on other sites More sharing options...
php1 Posted August 29, 2008 Author Share Posted August 29, 2008 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 https://forums.phpfreaks.com/topic/121827-solved-how-to-clear-the-text-box-value-by-clicking-on-reset-button/#findComment-628545 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.