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 4 of 4

Thread: using eval()

  1. #1
    Regular Coder
    Join Date
    Dec 2003
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using eval()

    ive made a funny program using eval()...
    it will let the person(on the page) to write javascript and have it compile(if thats the right word for it)!
    its quite cool, i dont know how handy it might be, but here it is none the less...

    code:
    <html>
    <head>
    <title>test</title>
    <script language="JavaScript">

    function submitCode(){
    var the_code = window.document.form_1.textarea_1.value;
    var run_the_code=eval(the_code);
    }

    </script>
    </head>
    <body>
    <center>
    <h1>write some code!</h1>
    <form name="form_1">
    <textarea name="textarea_1" rows=10 cols=40>
    </textarea>
    </form>
    <form onSubmit="return false;">
    <input type="submit" value="submit your code" onClick="submitCode();">
    </form>
    </center>
    </body>
    </html>

    very simple stuff, but for those of you who are unfamilir with eval, its pretty cool, huh?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    But have you searched this forum regarding the bad effect of eval? This topic is discussed intensively here.

  • #3
    WA
    WA is offline
    Administrator
    Join Date
    Mar 2002
    Posts
    2,596
    Thanks
    2
    Thanked 19 Times in 18 Posts
    Hi:
    Thanks for the submission, though due to what glenngv said and just the overall limited usefulness of this script, I'll be deleting this thread shortly.

    Thanks,
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.

  • #4
    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
    i would say that this is actually one of the few good uses of eval. i personally, have found exactly this set up to be amazingly helpful in the development stages of code, as i noted here:

    nifty use for eval()
    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.


  •  

    Posting Permissions

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