Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    North of Boston
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using the Eval function.

    The eval function is supposed to evaluate a mathmatical expression?

    So if I have a text box and the user enters say 2+2 how would I code the eval function so it will return the result correctly.
    I have been trying to do this but I can not get it to work correctly.

    Thanks
    bedardinc.com
    A+,Network+, MCP W2K
    Sites I have worked on
    patriotsweekly.com
    smileysbookstore.com

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    var mathExpression = "2+2";
    var mathAnswer;
    mathAnswer = eval(mathExpression);
    alert(mathAnswer);

    get it?
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    New Coder
    Join Date
    Jun 2002
    Location
    North of Boston
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    I get it. Thanks
    bedardinc.com
    A+,Network+, MCP W2K
    Sites I have worked on
    patriotsweekly.com
    smileysbookstore.com


  •  

    Posting Permissions

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