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 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  ;

            }
View Answers









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,ADS_TO_REPLACE_1 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.ADS_TO_REPLACE_1 For more information, visit the following links: http://www.roseindia.net/xml/ http://www.roseindia.net/xml/dom
JavaScript
JavaScript  clone JavaScript
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
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, This is sinduri, i want to learn javascript, so plz can u help me.how to learn
javascript
javascript  hi sir, if i want to learn javascript. what concepts i want to know
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:ADS_TO_REPLACE_1 form.jsp: <html> <script>... Javascript value In JSP"> <% String st=request.getParameter("msg"); if(st
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:<
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
Javascript
Javascript  <html> <head> <script type="text/javascript"> function validateForm() { var sname=document.getElementById('spocname'); var scontact=document.getElementById('spoccontact'); if(sname.value.length
javascript
javascript
javascript  how to create random question using javascript?   <html> <script> function displayQuestions() { document.getElementById("text").value=" "; var Questions = new Array(20
javascript
javascript
javascript  Hi deepak, sample example on javascript form validation   <html> <script> function checkName(text) { if(isNaN(text)){ return 1; } else{ alert("Please enter a valid name. The only charachters
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
What is JavaScript?
, and string libraries W3C DOM support in the JavaScript. For other JavaScript...What is JavaScript?  Hi, Sometime the students trying to know make... is Java script and other java related queries. How to define what is JavaScript
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
JavaScript - JavaScript Tutorial
JavaScript's HTML DOM window object method clearTimeOut() method is used to stop...JavaScript - JavaScript Tutorial JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find
JavaScript types
JavaScript types  What are JavaScript types
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
javascript doubt
javascript doubt  How to retrieving the values from Database by using javascript
JavaScript and ECMAScript
JavaScript and ECMAScript  What?s relationship between JavaScript and ECMAScript
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
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 Examples
of the DOM (Document Object Model) scripting.  JavaScript... JavaScript Examples     Clear cookie example Cookies can... using JavaScriptJavaScript getElementById innerHTML In JavaScript
JavaScript - JavaScript Tutorial
JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find most of the things about java script. JavaScript tutorial is classified into sections with examples. This tutorial
JavaScript - JavaScript Tutorial
JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find most of the things about java script. JavaScript tutorial is classified into sections with examples. This tutorial
ModuleNotFoundError: No module named 'dom'
ModuleNotFoundError: No module named 'dom'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'dom' How to remove the ModuleNotFoundError: No module named 'dom' error
Prototypes for JavaScript
Prototypes for JavaScript  What's Prototypes for JavaScript
Prototypes for JavaScript
Prototypes for JavaScript  What's Prototypes for JavaScript
What is JavaScript? - Definition
libraries W3C DOM support in the JavaScript Disadvantages of JavaScript... What is JavaScript? - Definition  ... the basics of JavaScript and create your first JavaScript program. What
javascript and database
javascript and database  i want to connect javascript pages with msaccess (as a database)how can i do so
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 query
javascript query  how to get javascript variable value into java variable?? i have one value in javascript variable(var name = value ) i want this name variable value in java variable (string name1

Ads