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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call variable from other frame

Status
Not open for further replies.

Bobs390

Technical User
Aug 4, 2004
13
GB
I am trying to get the value of a variable from another frame called middle which has a procedure called validform() in it. Within this function is a variable called checkok.

I am using the following function called fom a button, in the other frame called bottom, which tries to call the variable checkok in frame middle, but it doesnt seem to work. Any clues?
Thx

Code:
<script type="text/javascript">
<!--
function submitform(){
var checkok2 = parent.middle.checkok;
if (checkok2 >0){
parent.middle.document.faultform.submit()
}
else{ 
parent.middle.document.faultform.onsubmit();
}
}
//-->
</script>
 

Does changing this:

Code:
parent.middle.checkok;

to this:

Code:
parent.middle.document.checkok;

make any difference?

Dan
 
Nope. Also if I check it from alert(checkok) it says undefined.

I am sooo stuck with this, and it doesnt make any sense.
 
Try:

parent.frames["middle"].checkok

Also, make sure checkok is a global variable in the middle frame (i.e., declared OUTSIDE of function, but still within the SCRIPT tags).

--Dave
 
Hi, Thank you both for your help with this.

I think that checkok isn't a global variable as it seems to be only within the function.

Excuse my lack of knowledge with this (I'm a designer not a programmer! :) ) but if I were to declare checkok as a global variable so it works outside the function as well, how would I do that?

Thanks again.
 
example of locally declared variable:

Code:
<script>

function someFunction()
{
 var someVar = 1; [b]//inside function; i.e., local.[/b]
}

</script>

example of global variable:

Code:
<script>
var someVar = 1; [b]//still between SCRIPT tags, but not inside a function; i.e., global[/b]

function someFunction()
{
}

</script>

'hope that helps.

--Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top