Results 1 to 2 of 2

Thread: javescript

  1. #1
    Join Date
    Apr 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default javescript

    I am new and javescript. I am having a few problems with this page of a site i am helping a friend make.

    It will not work at all IE 8 debugger says 'null' is null or not an object and higlights

    Code:
    var news = selectnews.options (selectnews.selectedIndex).InnerHTML
    I have no idea what this means.

    and ever time I click submit it tries to load a page that dose not exist and i am not sure why.










    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!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">
    
    <head>
    
    <!--
            
            Webpage project
            
            Author: 
            Date:   
            
            File name: Mailinglist.htm
        
    -->
    <title>Home</title>
    <link href="mario.css" rel="stylesheet" type="text/css" />
    <script src="random.js" type="text/javascript">
    </script>
    <script src="ads.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    //<![CDATA[
    
    
    
    function valmail() {
    	
                    var lastName = document.Infoform.LastName.value;
                    var firstname = document.Infoform.FirstName.value;
                    var mi = document.Infoform.Mi.value;
                    var address = document.Infoform.Address.value;
                    var city = document.Infoform.City.value;
                    var state = document.Infoform.State.value;
                    var zip = document.Infoform.Zip.value;
                    var phone = document.Infoform.Phone.value;
                    var dob = new Date (document.Infoform.Dob.value);
                    var res = document.Infoform.chkResident.value;
                    var email = document.Infoform.email.value;
                    var cemail = document.Infoform.cemail.value;
                    var stuClass;
                    var classChecked = false;
                    var selectnews = document.getElementById('lstF_ID');
                    var news = selectnews.options (selectnews.selectedIndex).InnerHTML
                    var radio = document.Infoform.Class.value;
                                    
                    
                            for (var i=0; i < document.Infoform.Class.length; i++) {
                                    if (document.Infoform.Class[i].checked) {
                        classChecked = true;
                        stuClass = document.Infoform.Class[i].value;
                                    }
                            }
                    
                if (lastName == "") {
                            alert ("Please enter a last name");
                            document.Infoform.LastName.select();
                            return false;
                            
                            
                } else  if (firstname == "") {
                            alert ("Please enter a first name");
                            document.Infoform.FirstName.select();
                            return false;
                            
                }else if (address == "") {
                            alert ("Please enter a address");
                            document.Infoform.Address.select();
                            return false;
                            
                } else if (city == "") {
                            alert ("Please enter a city");
                            document.Infoform.City.select();
                            return false;
                            
                } else if (state == "") {
                            alert ("Please enter a state");
                            document.Infoform.State.select();
                            return false;
                            
                } else if (zip == "") {
                            alert ("Please enter a zip");
                            document.Infoform.Zip.select();
                            return false;
                            
                } else if (phone == "") {
                            alert ("Please enter a phone");
                            document.Infoform.Phone.select();
                            return false; 
                            
                }else if (dob == "NaN") {
                                            
                                    alert ("Date of Birth is not valid, use MM/DD/YYYY to enter data");
                                    document.Infoform.Dob.select();
                                    return false;
                                                                    
                            }else if (email ==""){
                                    alert ("please enter an email address")
                                        return false;
                                            
                            }else if (cemail =="") {
                                    
                                    alert ("please enter an email address")
                                        return false;
                                            
                            }else if (cemail != email) {
                            
                            alert ("Make sure your emails and the same.")
                                        return false;
                                    
                            } else
                                    
                                    {
                                    alert ("Last name: " + lastName + "\n" + "First Name: " + firstname + "\n" + 
                    				"mi: " + mi + "\n" + "Address: " + address + "\n" + "City: " + city + "\n" + 
                   					 "State: " + state + "\n" + "Zip: " + zip + "\n" + "phone: " + phone + "\n" +
                                    "Date of Birth: " + dob + "\n" + "News: " + news + "\n" + 
                                    "contect: " + stuClass + "\n" + "Email: " + email);
                    					return true;
                            
                            		}
    }
    
    //]]>
    </script>
    </head>
    <body>
    <h5><script type="text/javascript">
    //<![CDATA[
     
     
            rNumber = randInt(5); //generate a random integer from 1 to 5
            rAd = adDescription(rNumber); // description of the random ad
            rLink = adLink(rNumber); // url of the random ad
     
            document.write("<a href=" + rLink + ">");
            document.write("<img src='ad" + rNumber + ".jpg' alt='" + rAd + "' />");         
            document.write("<\/a>");
                    
    //]]>
    </script></h5>
    <hr />
    <a href="Home.htm">Home</a> <a href="speedrun.htm">Speed Runs</a> <a href="History.htm">History</a> <a href="mailinglist.htm">Mailing List</a> <a href="games.xml">List of games</a>
    <hr />
    <h3>Mario Mailing List</h3>
    
    <form name="Infoform" action="action%20marker" id="Infoform" onsubmit="valmail()">
    <table>
    <tr>
    <td>Last Name:</td>
    <td><input type="text" name="LastName" size="20" /></td>
    <td></td>
    <td>Contact prferred:</td>
    <td>
    <h4>&nbsp;</h4>
    </td>
    <td></td>
    </tr>
    <tr>
    <td>First Name:</td>
    <td><input type="text" name="FirstName" size="20" /></td>
    <td></td>
    <td><input type="radio" name="Class" value="Mail" />
      Mail</td>
    <td>&nbsp;</td>
    <td></td>
    </tr>
    <tr>
    <td>MI:</td>
    <td><input type="text" name="Mi" size="5" /></td>
    <td></td>
    <td><input type="radio" name="Class" value="email" /> 
       Email</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Address:</td>
    <td><input type="text" name="Address" size="20" /></td>
    <td></td>
    <td><input type="radio" name="Class" value="email" /> 
      Phone</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>City:</td>
    <td><input type="text" name="City" size="20" /></td>
    <td></td>
    <td><input type="radio" name="Class" value="text" /> 
      Text</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>State:</td>
    <td><input type="text" name="State" size="5" /></td>
    <td></td>
    <td><input type="radio" name="Class" value="any" />
      Any</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>ZIP Code:</td>
    <td><input type="text" name="Zip" size="20" /></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td>Phone:</td>
    <td><input type="text" name="Phone" size="20" /></td>
    <td></td>
    <td><input name="chkResident" type="checkbox" /> 
       All of the above</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>Date of Birth:</td>
    <td><input type="text" name="Dob" size="20" /></td>
    <td></td>
    <td>What news do you want to here about?</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>EMail:</td>
    <td><input type="text" name="email" size="20" /></td>
    <td></td>
    <td><select size="1" name="lstF_ID">
      <option selected="selected" value="1">New speed runs</option>
      <option value="2">upcoming games</option>
      <option value="3">New bugs found</option>
      <option value="4">new speed runs</option>
      <option value="5">All</option>
    </select></td>
    <td></td>
    </tr>
    <tr>
    <td>confirm email:</td>
    <td><input type="text" name="cemail" size="20" /></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" value="Submit" /></td>
    </tr>
    </table>
    </form>
    <hr />
    <address>All information taken from mario wiki</address>
    </body>
    </html>

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there iamhere666,

    and a warm welcome to these forums.

    Change this...
    Code:
    
    <select size="1"  name="lstF_ID">
    
    ...to this...
    Code:
    
    <select size="1"  name="lstF_ID"  id="lstF_ID">
    
    ...and this...
    Code:
    
    var news = selectnews.options(selectnews.selectedIndex).InnerHTML
    
    ...to this...
    Code:
    
    var news = selectnews.options[selectnews.selectedIndex].innerHTML
    
    coothead
    Last edited by coothead; 04-27-2011 at 11:58 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •