JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 18th, 2003, 01:31 PM
harvey_r01 harvey_r01 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Bournemouth
Posts: 37 harvey_r01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
eval and function calling

Hi All,

I'm a newbie to javascript and was hoping for some help. The goal is to add some text to a textarea via an input button. So my JS:
//mainInput = name of textarea
function addtext(formname,reqText) {
insert = true;
if (insert)
{
eval(formname + '.' + mainInput + '.value += \"<\"' + reqText + '\">\";');
}
eval(theform + '.' + mainInput + '.focus();');
}

I recieve an Expected ";" error from IE for the eval line. The strange thing is if i move the semi-colon to -1 of the closing eval bracket i.e. eval('whatever'; I recieve a different error saying Object Expected, referring to the line with the input button which calls function addtext:
<input type="button" value="Harvey" onclick="addText(this.form,'harvey')" title="Harvey" accesskey="h">

...even stranger, is that if i do move the semi-colon to left of the closing eval bracket, no alert statements are executed??

does anyone have any ideas, i will be very grateful...

Thanks All,

Harvey

Reply With Quote
  #2  
Old December 18th, 2003, 01:50 PM
harvey_r01 harvey_r01 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Bournemouth
Posts: 37 harvey_r01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
no worries...

...just realised how stupid i was being, i didn't have the formname in the quotes, due to it being an object and not a string....

cheers anyway...


Harvey

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > eval and function calling


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT