Javascript DOM

Ads

 
 

Share on Google+Share on Google+

tom mcbain
Javascript DOM
0 Answer(s)      6 years and 6 months ago
Posted in : JavaScript Questions
I'm getting into client-side scripting using javascript.

I am attempting to build a football team fixture application. The user would able to enter the number and name of the teams and then applicaion would generate a fixture list. I was knocking about using DOM techniques but with minimal success. I used  a nested for loop for generating the fixture list but it's not would I'd like. I would like to generate the fixtures on a weekly basis.

I've included code for anyone to view and offer advice.

The following code is the HTML page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/footballTemp.dwt" codeOutsideHTMLIsLocked="false" -->

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- InstanceBeginEditable name="doctitle" -->

<title>Star Football</title>

<script language="javascript" type="text/javascript" src="selectTeamNo.js">

</script>



<!-- InstanceEndEditable -->

<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->

<link href="styles.css" rel="stylesheet" type="text/css" />

</head>



<body>



  <div id="logo">

    <img src="images/starfootball.png" alt="starFootballlogo" width="453" height="105" />

  </div>



<div id="menu"><a href="home.html">Home</a> | <a href="sponsorship.html">Sponsorship</a> | <a href="news.html">News</a> | <a href="weather.html">Weather</a><a href="#"></a> |  <a href="blogger.html">Blogger</a> | </div>

<div id="content"><!-- InstanceBeginEditable name="content" -->



<div id = "heading">Star Football League</div><br /><br />

     <div id = form1>   <form name="form1">

            <table width="380">

  <tr>

                    <td colspan="2" align="left"><b>Input Team</b>

                      <b>&nbsp;:</b>

                  <td width="276">

                <input type="text" name="name"/>                </tr>

                <tr>

                    <td width="82" align="right">

                  <td width="33">

              <td width="276">                </tr>

                <tr>

                    <td width="82" align="right">

                  <td width="33">

                  <td width="276">

                <input type="button" Value="Submit Team" 

                     onclick="insert(this.form.name.value),show();"/>

                <input type="button" Value="Fixtures" 

                     onclick="insert(this.form.name.value),show2();"/>

                    </tr>

            </table>

        </form>

        </div>

        <table width="561" height="62" border="2" bordercolor="#FFFFFF">

  <tr><td width="181" height="54" align="left" valign="top"> <div id="myDiv"></div></td>

  <td width="169"><div id="myDiv2"></div></td></tr></table>

<!-- InstanceEndEditable --></div>

<div id="footer">Copyright 2010 starfootball.com</div>

</body>

<!-- InstanceEnd --></html>

**//This is the javascript code I used from an external file**

var array = new Array();
   //Create new method/fuction
            function insert(val){
                array[array.length]=val;
            }
            function show() {
                var string="<b>These are the chosen teams :</b><br>";
                j = 8
    for(i = 0; i < 8; i++) {
                    string =string+array[i]+"<br>";
                }
                if(array.length > 0)
                 document.getElementById('myDiv').innerHTML = string  ;

            }



    var hometeam = new Array();
    var awayteam = new Array();
    function show2() 
       {
        var string
        hometeam = array
        awayteam = array
                var string2="<tr><td><b>Fixtures :</b><br></td></tr>";
                for(i = 0; i < 8; i++) {
     for(j = 1+i; j < 8; j++) {
      string2 =string2+hometeam[i]+" &nbsp;&nbsp; vs &nbsp;&nbsp;" +hometeam[j]+"  "+"<br>";
     }
                }


     if(hometeam.length > 0)
                 document.getElementById('myDiv2').innerHTML = string2  ;

            }
Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
javascript dom error-message
javascript dom error-message  javascript dom error-message
Javascript DOM
Javascript DOM  I'm getting into client-side scripting using javascript. I am attempting to build a football team fixture application. The user... generate a fixture list. I was knocking about using DOM techniques but with minimal
Advertisements
DOM
DOM  hello, What is DOM?   hii, DOM is stands for Document object Model. DOM is an interface-oriented Application Programming Interface. We can use it for navigation of the entire document
DOM
DOM  package name for Document class?   Hi Friend, The package is known as dom api. For more information, visit the following links: http://www.roseindia.net/xml/ http://www.roseindia.net/xml/dom/ Thanks
DOM to SAX and SAX to DOM - XML
DOM SAX Parser Java  What is the Difference between SAX and DOM parsers
DOM to SAX and SAX to DOM - XML
Java DOM to SAX and SAX to DOM  Simple API for XML and Document Object Model
DOM - XML
DOM  Hi... I created an xml file through java by using DOM Now..I need to get the prompt for download when i clicked the button... I used downloadaction...for this But it didn't worked.. Its jus viewing the xml file
Dom in java
Dom in java  Exception in thread "main" org.w3c.dom.DOMException: INVALIDCHARACTERERR: An invalid or illegal XML character is specified... Create XML using DOM import java.io.*; import org.w3c.dom.*; import
DOM - XML
DOM  Hello.... I'm creating an xml file from java using DOM... from the database values... and saving it in a file But the created xml file is generating all its files in a single line.. But i need to get the next tag
JavaScript
JavaScript  clone JavaScript
dom to xml string
dom to xml string  Hi, I am writing a program in java that reads... have save the dom document into xml file. How to convert dom to xml string... for converting DOM object into string data. Please check the thread dom to xml
javascript
javascript  javascript code to dynamically add table on button click.../javascript/javascriptexamples/javascript-add-row-dynamically.shtml http://www.roseindia.net/javascript/javascript-add-row-to-table.shtml http://www.roseindia.net
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
JavaScript clearTimeOut method
JavaScript clearTimeOut method       JavaScript's HTML DOM window object method.... In this section of JavaScript methods tutorials we will be able to clear the set time out
JavaScript
should use JavaScript? Thanks   Hi, JavaScript is scripting language that runs on browser. You have to embed JavaScript in HTML page. Please see JavaScript tutorial. Thanks
JavaScript
JavaScript  how to get full path of a file type in javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
javascript
javascript  write a program to display implement about browsers using javascript
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
javascript
javascript  how to set the request or session attribute in javascript head part of jsp page
javascript
javascript  hi sir, if i want to learn javascript. what concepts i want to know
javascript
javascript  Hi sir, This is sinduri, i want to learn javascript, so plz can u help me.how to learn
JAVASCRIPT
JAVASCRIPT  I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ? thanks in advance
Javascript
Javascript   Javascript to check Numeric entry in checkbox.....   Hi Please find the following code for numeric entry validation in javascript function validateBox(){ var data=document.myForm.someText.value
javascript
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
javaScript
javaScript  . Print a table like below in JAVASCRIPT 5 x 1 = 5 5 x 2 = 10 ΓΆβ?¬Β¦ΓΆβ?¬Β¦ΓΆβ?¬Β¦. 5 x 20 = 100
javascript
javascript  passing javascript values to jsp   Hi Friend, Try the following code: form.jsp: <html> <script> function getMsg...;/script> <input type="button" onclick="getMsg();" value="Get Javascript value
Javascript
this format xxx-xxx-xxxx, i want the code in javascript. as a function.   Javascript Phone Number Validation <html> <script> function..." method="post" onsubmit="javascript:return validate();"> Phone Number:<
Document Object Model(DOM)
to use DOM in order to render an HTML document. However, JavaScript scripts... Document Object Model(DOM)       The Document Object Model (DOM) is a an standard object model
Javascript
Javascript  Dear Sir, Thank You a lot for your continuos support.Again i am in need of your help. What is the javascript code to disable a link,once... javascript or css Please help me.Urgent Regards Debasis   Hello Friend