Results 1 to 3 of 3

Thread: Why this is not working?

  1. #1
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Why this is not working?

    Script::.
    Code:
    <script language="javascript">
    function temp(form)
    {
    	oops = "";
        var sum = 0;
            var fld = (form.level.value);
    		var val = fld.value.replace(/\s/g, "" );
    		if ( val != "")
    		{
    			var deg = parseFloat(fld.value);
                if ( isNaN(deg) || deg < 0)
    			 {
                    fld.value = "0";
                    oops += "\nInvalid Level";
                } else if ( deg != 0 ) {
                    sum += Math.pow( deg, 3 );}
    		}
    		if ( oops != "" )
        {
            alert("You must correct these errors:\n" + oops);
            return false;
        }
           form.totalexp.value = sum ;
    }
    </script>
    Html::.
    Code:
    <form style="text-align:center">
    <p>Level</p>
    <p><input size=30 maxlength=30 value=0 name="level" onfocus="this.value=''"/></p>
    <input type=button onclick=temp(this.form) value=Calculate /> 
    <input type=reset name=clear id=clear value=Clear /></p>
    <blockquote><p>Total Exp <input name="totalexp" size=40 maxlength=40 readonly=""/></p></blockquote></form>
    Can someone help me. Whats wrong with my js code and i am noob to J.S.
    Your help is most appreciated.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Get rid of the highlighted:

    Code:
    function temp(form)
    {
    	oops = "";
        var sum = 0;
            var fld = (form.level.value);
    		var val = fld.val . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Darkmirror (11-01-2009)

  4. #3
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much for ur time!

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
  •