Link to home
Start Free TrialLog in
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMPFlag for United States of America

asked on

PHP, HTML, & Javascript . . . need help debugging. URGENT

Code:

----------------------------------------------------------------------------------------------------------------------------------------------------------------
someurl.htm

<html>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <title>Sayhi2me Advertisement</title>
</head>

        <frameset rows="25%,75%">
               <frame src= "index.htm" name ="sidemenu" noresize scrolling ="yes">
               <frame src= "http://www.google.com" name = "mainwindow">
        </frameset>

<body>


</html>

----------------------------------------------------------------------------------------------------------------------------------------------------------------
index.htm


<html>

<?php
   $conn = mysql_connect("localhost", "user", "****");
   

   mysql_select_db("trivia", $conn);
   
   

   $id = 1;
   $sql = "SELECT Question,Answer1,Answer2,Answer3,Answer4,Answer5,UserLink,Correct FROM `trivia questions` where ID=$id";  


   $result     = mysql_query($sql, $conn);

   $q = mysql_result($result, 0, "Question");

   $a1 = mysql_result($result, 0, 'Answer1');
   $a2 = mysql_result($result, 0, 'Answer2');
   $a3 = mysql_result($result, 0, 'Answer3');
   $a4 = mysql_result($result, 0, 'Answer4');
   $a5 = mysql_result($result, 0, 'Answer5');
   $answer = mysql_result($result, 0, 'Correct');
   $link = mysql_result($result, 0, 'UserLink');

?>


<form name="myForm">
<body onload="getStarted()">
<h3>You must browse this page for:
   <input name="numberShown" type="text" size="2" align="right" onfocus="this.blur()">
 more seconds. <span style="visibility:hidden" id="word"><font color="FF0000">Secret Word: <?PHP $id ?> </font></span></h3>
</body>
</form>



<SCRIPT LANGUAGE="JAVASCRIPT">
parent.main.location.href=" <?PHP print($link) ?>";


function getStarted() {
  //-- Loads the number 10 into the form field.
  parent.myForm.numberShown.value="5"
  //-- Pauses one-second, then calls the subtractOne function.
  myTimer=setTimeout("subtractOne()",1000)
}
function subtractOne() {
  //Subtract 1 from current value in form field.
  var newValue = parseInt(document.myForm.numberShown.value)-1
  //Replace the contents of form field with smaller number.
  document.myForm.numberShown.value = newValue

  //-- If countdown hasn't reached zero, pause then do it again.
  if (newValue > 0) {
    //-- From here on out, this function calls itself once every second.
    myTimer=setTimeout("subtractOne()",1000)
  //-- When countdown does reach zero, stop the timer and call reachedZero().
  }else{
    clearTimeout("myTimer")
    reachedZero()
  }
}

function reachedZero() {
    alert($id);
}

</html>
----------------------------------------------------------------------------------------------------------------------------------------------------------------


Here's what I'm trying to do:


Current:
someurl splits browser into 2 frames.  Loads google in 1, my scripts in another.

Needed:
load link where google is, get scripts working, then reload the frame where the scripts were executed to another php page (I want to create it in this file though.)

What the scripts do:
It's a countdown.  

So go visit $link, meanwhile other side counts down, when countdown reaches zero, want to generate a question (I already have the code for this, just need to know how to move into and out of java script.)  PLEASE HELP!



ASKER CERTIFIED SOLUTION
Avatar of sarahk
sarahk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kyle Abrahams, PMP

ASKER

YOU ROCK!
quick question:

instead of www.google.com in index.html we have $link for the user link.

link has to be the same link as link in bit.php.  

is there a simple way to redirect mainwindow?

never mind, got it:

First line of GetStarted should be:

  parent.frames['mainwindow'].location.href = "<?php print($link) ?>";