Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing values in frames

Status
Not open for further replies.

villan

Programmer
Jul 5, 2001
6
GB
As a rule I have always avoided frames at all costs, thus my complete lack of knowledge on the subject:

I have page with two frames, one called "top" & one called "bottom".

"Top" has a textbox with a value in it. I would like to display the value of the textbox in "bottom"

I just need the VBscript for this, so it works like this:

x = (textbox in "top"'s value)
response.write x

Thanks in advance

- Villan.
 
not sure about the vbscript, but the client side javascript would be:

parent.frames[index].formName.elementName.value

this would reference the value of the form element.

Where 'index' is probably 0 for the top frame and 1 for the bottom frame.

If you absolutely MUST use vbScript, then the syntax probably won't be far from what I've posted.
penny.gif
penny.gif
 
Thanks mate, I've tried all sorts of variations, but none work. The best advised answer I've recieved is to use the following:

x = parent.bottom.form1.text1.value
response.write x

However this does not work.I have to have it in VBScript, as the variables are needed server-side & i don't know much about client-side Javascript.
 
Looks like you are trying to access the values in server side script. That isn't going to work.

For example,

x = parent.bottom.form1.text1.value

is not valid ASP (server side) code. You will not be able to access window objects from ASP code, as windows are client side objects.

So, put this bit of code in 'bottom'

<script language=javascript>
function fillValue(){
document.formName.elementName.value = parent.frames[0].formName.elementName.value;
}
</script>

And call it onLoad in the bottom frame like this:

<body onLoad=&quot;fillValue();&quot;>

And also call it onBlur in the main window on that particular text box like this:

<input type=text name=elementName onBlur=&quot;parent.frames[1].fillValue();&quot;>

In the above code, I'm assuming that the index of your frames are:
bottom --> 1
main --> 0

And of course, you'll have to replace 'formName' with the actual names of your forms, and 'elementName' with the actual value of your text boxes.

Calling the function in both places should keep the values synchronized.

hope that helps out! :)
Paul Prewett
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top