1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Javascript help needed quick!

Discussion in 'JavaScript' started by Light Speed, Oct 22, 2009.

  1. #1
    function displayNewDocument()
    {
    document.open([averagempg], [gallonsofgas], [reservetank]);
    document.write(<html>);
    document.write('the values you input were '+ averagempg', ' + gallonsofgas +', and' reservetank);
    document.write(/html>);
    document.close();
    }
    Code (markup):

    this doesnt open a document, plus i get an error saying displayNewDocument not defined!



    full script here:


    
    <html>
    
    <script type="text/javascript">
    var averagempg;
    var gallonsofgas;
    var reservetank;
    var gallonsanswer;
    var answer;
    
    
    averagempg = prompt('Please enter your vehicles average mpg rating.');
    gallonsofgas = prompt('Please enter the number of gallons of gasoline currently in your vehicle.');
    reservetank = prompt('Please enter the number of gallons of gasoline in the reserve gas tank of your vehicle.');
    
    averagempg = parseFloat(averagempg);
    gallonsofgas = parseFloat(gallonsofgas);
    reservetank = parseFloat(reservetank);
    
    gallonsanswer= gallonsofgas+reservetank;
    answer = averagempg * gallonsanswer;
    
    
    
    alert('With the available gas you have, you will be able to travel ' + answer + ' more miles.' );
    
    
    function displayNewDocument()
    {
    document.open([averagempg], [gallonsofgas], [reservetank]);
    document.write(<html>);
    document.write('the values you input were '+ averagempg', ' + gallonsofgas +', and' reservetank);
    document.write(/html>);
    document.close();
    }
    
    
    </script></head>
    
    <body onload="displayNewDocument()">
    </body></html>
    Code (markup):
     
    Light Speed, Oct 22, 2009 IP