Thread: Javascript?
View Single Post
Old Mar 6, 2012 | 07:21 PM
  #1  
haz87's Avatar
haz87
PassionFord Post Whore!!
20 Year Member
Liked
Loved
 
Joined: Aug 2004
Posts: 3,501
Likes: 184
From: Colchester,essex
Default Javascript?

Any javascript pro's in the house?

I need to create a very basic "choices" page.


The skeleton code
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<style>
     body{font-family: Arial,sans-serif; background-color: #86bfc9;}
     #content{float:right; width: 75%;}
</style>
<script type = "text/javascript">
   function showit(what,where)
   {
        var node = document.getElementById(where);
        while( node.firstChild )
            node.removeChild( node.firstChild );
        node.appendChild( document.createTextNode(what) );
   }
   function hello()
   {
     alert("Hello World");
   }
   function timestable()
   {
str="you code times table here";
showit(str,"Results");
   }
   function formattedtimestable()
   {
str="you code formatted times table here";
showit(str,"Results");
   }
   function alerttimestable()
   {
str="you code alert times table here";
// you code here
alert(str);
   }
   </script>
</head>
<body>
   <h1>JavaScript Exercises </h1>
   <div id="content"> <div id = "Results"></div> </div>
   <a href="#" OnClick = "hello()">Hello Alert</a> <br/><br/>
   <a href="#" OnClick = "timestable()">Times Tables</a> <br/><br/>
   <a href="#" OnClick = "alerttimestable()">Times table in an alert box</a>
   <br/><br/>
   <a href="#" OnClick = "formattedtimestable()">Times Tables in a Table</a>
   <br/><br/>
  </body>
</html>
Now i've written basic times tables script as a seperate entity but how the hell do i intcorporate it to the above

Code:
<html>
<body>
<table>
<?php
$values = range(1,12); // same as $values = array(1,2,3,4,5,6,7,8,9,10);
foreach($values as $side){ // Creates each row
    echo '<tr>';
    foreach ($values as $top){ // Creates each column
        $output = $side * $top; // multiplies the top value times the side value
        echo "<td>$output</td>";
    }
    echo '</tr>';
}
?>
</table>
</body>
</html>
If someone can just show me how it is written into the function then i can sort the rest out. Just need to work out one
Reply