PDA

View Full Version : Problem with dynamic link


skhoo
01.06.2001, 10:04
Hi, I hope someone could help me with array of links.

I have 2 frames, topFrame and mainFrame. The pages are navigated with a button in the topFrame called goNext(). It includes :

var quiz = new Array()

quiz[0] = new quizPage("te_sc1.htm")
quiz[1] = new quizPage("te_sc2.htm")
quiz[2] = new quizPage("te_sc3.htm")

function goNext() {
var currPage, i
for (i=0; i<(quiz.length-1); i++) {
if (parent.mainFrame.location.href.indexOf(quiz[i:aoonskzvxm].src) != -1) {
parent.mainFrame.location.href = quiz[i+1].src
break
}
}
}

It works fine. But my question is, how do I create another function goNext() and place it in each page in the mainFrame? I know I could hard code it to go to the next page, but is there a way i could communicate with the script in the topFrame from the mainFrame? Thanks.



Soon

manswide
01.06.2001, 12:21
I'd do something like this:

Topframe code:
<script>
quiznr=0
function goNext(){
if((quiznr++)==quizTot)return;
parent.mainFrame.location="te_sc"+quiznr+".html"
}
</script>

Where quizTot is the total number of "Quizpages". Now, for the button in the bottom frame you write like this:

<form>
<input type="button" value="next" onclick="parent.frames[0].goNext()">
</form>

That should do it.