Click to See Complete Forum and Search --> : Filling out a form from a drop-down list


jochem
11-10-2003, 10:16 AM
I have a code that works with text-links, but I would like it to work from a drop-down list. Here's the links code:


<html>
<body>

<div align="center">
<table border="2" width="280" cellspacing="5" cellpadding="15" bordercolor="#000000">
<tr>
<td width="239" bgcolor="#00FF00">
<form name="resize">
<input name="xval" size="5" value="640" class="forms">&nbsp; Window Width<br>
<input name="yval" size="5" value="480" class="forms">&nbsp; Window Height
</form>

<p align="center">
<a href="#" onclick="document.resize.xval.value='640',document.resize.yval.value='480'">640x480</a>,
<a href="#" onclick="document.resize.xval.value='800',document.resize.yval.value='600'">800x600</a>,
<a href="#" onclick="document.resize.xval.value='1024',document.resize.yval.value='768'">1024x768</a>,
<a href="#" onclick="document.resize.xval.value='1280',document.resize.yval.value='1024'">1280x1024</a>,
<a href="#" onclick="document.resize.xval.value='1400',document.resize.yval.value='1050'">1400x1050</a>,
<a href="#" onclick="document.resize.xval.value='1600',document.resize.yval.value='1200'">1600x1200</a>
</p>

</td></tr>
</table>
</div>

</body>
</html>


I tried this, but it doesn't do the job:


<p align="center">
<select class="select">
<option>Odd resolutions</option>
<option onselect="document.resize.xval.value='160',document.resize.yval.value='160'">160x160 : PalmOS</option>
<option onselect="document.resize.xval.value='176',document.resize.yval.value='160'">176x160 : Cell phone</option>
<option onselect="document.resize.xval.value='320',document.resize.yval.value='240'">320x240 : PocketPC</option>
<option onselect="document.resize.xval.value='320',document.resize.yval.value='320'">320x320 : PalmOS Hi</option>
<option onselect="document.resize.xval.value='640',document.resize.yval.value='240'">640x240 : WinCE</option>
<option onselect="document.resize.xval.value='544',document.resize.yval.value='372'">544x372 : WebTV</option>
</select>
</p>


Has anyone got any suggestions?

Cheers, Jochem :cool:

requestcode
11-10-2003, 11:56 AM
Try this:
<html>
<head>
<title>Test</title>
<script language="JavaScript">
function chgval(objval)
{
splitval=objval.split(",")
document.resize.xval.value=splitval[0]
document.resize.yval.value=splitval[1]
}
</script>
</head>
<body>

<div align="center">
<table border="2" width="280" cellspacing="5" cellpadding="15" bordercolor="#000000">
<tr>
<td width="239" bgcolor="#00FF00">
<form name="resize">
<input type="text" name="xval" size="5" value="640" class="forms"> Window Width<br>
<input type="text" name="yval" size="5" value="480" class="forms"> Window Height
</form>
<select name="sel1" onChange="chgval(this.options[this.selectedIndex].value)">
<option value="640,480">640x480</option>
<option value="800,600">800x600</option>
</select>
</td></tr>
</table>
</div>

</body>
</html>

jochem
11-10-2003, 03:57 PM
Cool! It works. Thanks for your help!

Case closed... :D