serbestgezer Posted April 18, 2012 Share Posted April 18, 2012 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <title>Untitled Page</title> <script type="text/javascript"><!-- var lastDiv = ""; function showDiv(divName) { // hide last div if (lastDiv) { document.getElementById(lastDiv).className = "hiddenDiv"; } //if value of the box is not nothing and an object with that name exists, then change the class if (divName && document.getElementById(divName)) { document.getElementById(divName).className = "visibleDiv"; lastDiv = divName; } } //--> </script> <style type="text/css" media="screen"><!-- .hiddenDiv { display: none; } .visibleDiv { display: block; border: 1px grey solid; } --></style> </head> <body bgcolor="#ffffff"> <form id="FormName" action="blah.php" method="get" name="FormName"> <select name="selectName" size="1" onChange="showDiv(this.value);"> <option value="one">first</option> <option value="two" selected>second</option> <option value="three">third</option> </select> <input name="two" id="two" type="text" class="hiddenDiv"> </form> </body> </html> Hi Everyone, I am trying to load input text with onchange but when you reflesh the page it doesnt work with selected value I guess I need to use the onload same time. I dont know how to use it. Any help much appriciated. Link to comment https://forums.phpfreaks.com/topic/261150-using-onload-and-onchange-help/ Share on other sites More sharing options...
serbestgezer Posted April 18, 2012 Author Share Posted April 18, 2012 Hey guys, after playing with it. Finally, I got it working. Cheers Link to comment https://forums.phpfreaks.com/topic/261150-using-onload-and-onchange-help/#findComment-1338325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.