Moderators: macek, egami, gesf


document.FormName.InputName.value = document.FormName.SelectName.selectedIndex1. SelectName.option[i].selected
2. SelectName.option[i].value
3. SelectName.option[i].name // not sure about name :P
// Where i, is the index of the option. Just like an array
<html>
<head>
<title>test1.html</title>
</head>
<body>
<form name='test1f' method='POST'>
Change me:<input name='test1i' value='JavaScript'>
<input type="button" value="Click here to Change the Input Value" onclick="window.open('test2s.html')">
</form>
</body>
</html>
<html>
<head>
<title>test2s.html</title>
<script type="text/javascript">
function changeinputvalue(){
document.test1f.test1i.value = document.test2f.test2s.selectedIndex;
}
</script>
</head>
<body>
<form name="test2f">
<select name="test2s" onChange="changeinputvalue()">
<option>HTML</option>
<option>PHP</option>
<option>MySQL</option>
</select>
<input type='submit' value='Submit'>
</form>
</body>
</html>


<html>
<head>
<title>test2s.html</title>
<script type="text/javascript">
function SetCategory(theForm) {
if(window.opener && !window.opener.closed) {
data = theForm.options[theForm.selectedIndex].value;
window.opener.document.test1f.test1i.value = data;
window.close();
}
}
</script>
</head>
<body>
<form name="test2f" onchange="SetCategory(this)">
<select name="test2s">
<option>HTML</option>
<option>PHP</option>
<option>MySQL</option>
</select>
</form>
</body>
</html>
Users browsing this forum: No registered users and 1 guest