...

View Full Version : using eval()



warhammerdude20
01-28-2004, 10:10 PM
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?

glenngv
01-29-2004, 05:43 AM
But have you searched this forum regarding the bad effect of eval? This topic is discussed intensively here (http://www.codingforums.com/showthread.php?s=&threadid=20143).

WA
01-29-2004, 09:30 AM
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,

joh6nn
01-29-2004, 09:29 PM
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:

http://www.codingforums.com/showthread.php?s=&threadid=5772



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum