return a value to a parent window

waqas
06-12-2002, 11:29 AM
how can i return a value from child winow to parent using vb script ?.

this is combo.html file
<html>
<head>
<script language="vbscript">
function zReturn()
val = document.myForm.mySelection.options(1).value
zReturn = val
end function
</script>

</head>
<body onunload="zReturn()">
<form name="myForm">
<select name="mySelection">
<option value="Zero">Zero</option>
<option value="One">One</option>
<option value="Two">Two</option>
<option value="Three">Three</option>
</select>
<input type="button" value="close" onclick="window.close()" id=button1 name=button1>
</form>
</body>
</html>


now in my message box i open this window but it doesn't return the value,
I m doing this in my asp page


<script language=vbscript>

function checkcombo()
val = window.open("combo.html","","height=200,width=400")
end function

</script>



waqas

ChiefRedBull
06-12-2002, 02:15 PM
<script language="vbscript">
function zReturn()
val = document.myForm.mySelection.options(1).value
zReturn = val
end function
</script>

This code won't do anything, because its not accessing the parent window. You can access the parent window via the window.opener property. This property is a window object.

I would suggest the function looks more like this:
<script language="vbscript">
function zReturn()
val = document.myForm.mySelection.options(1).value
window.opener.someEventFunction val
end function
</script>

Thus calling a sub or function on the parent, passing the variable as a parameter. I would assume that this would work... although I haven't tried it...

altered document.opener to window.opener as per waqa results below

waqas
06-12-2002, 02:27 PM
i tried this but it gives me following error

"Object doesn't support this property or method 'document.opener' "

thanks
waqas

waqas
06-12-2002, 02:29 PM
well it worked fine when i changed document.opener to window.opener....


Thanks a lot chief

waqas

ChiefRedBull
06-12-2002, 02:32 PM
Whoops!! My mistake... careless. sorry waqas :(

Still, you got there in the end - well done!! :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum