...

View Full Version : onchange dropdown value hide row



ahussain
08-20-2007, 10:59 PM
Hi,

I am very new to javascript. I tried to hide row on changing dropdown select
value. Please correct me where I am mistaking. Any hint will be highly appreciated my code is:-

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
function showHide(type){
if(type == 'code'){
document.getElementById('trText').style.display = 'block';
else{
document.getElementById('trText').style.display = 'none';
}


}

</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
</head>

<body>
<form name="form1" id="form1" method="post" action="">
<p>&nbsp;</p>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td><select name="select" onchange="showHide(this.Value)">
<option value="0">abc</option>
<option value="1">def</option>
</select></td>
</tr>
<tr id="trText" style="display:none ">
<td><input type="text" name="textfield" /></td>
</tr>
</table>
<p>&nbsp; </p>
</form>
</body>

Note: The error I am receieving is object is expected. Kindly correct me where exactly im mistaking..

Arty Effem
08-21-2007, 12:05 AM
Note: The error I am receieving is object is expected. Kindly correct me where exactly im mistaking..



onchange="showHide(this.Value)"

Should be
onchange="showHide(this.value)"Also the select is going to pass only "0" or "1", but showHide is expecting 'code'.

rwedge
08-21-2007, 01:39 AM
Also, your if/else is missing a '}'

if(type == 'code'){
document.getElementById('trText').style.display = 'block';
} else {
document.getElementById('trText').style.display = 'none';
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum