Jump to content

using onload and onchange help!!!


serbestgezer

Recommended Posts

<!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

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.