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. Quote Link to comment 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> Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.