Connecting Tech Pros Worldwide Help | Site Map

Don't see the error here

Fetty
Guest
 
Posts: n/a
#1: Jul 23 '05
<script language="JavaScript">
function copyComment(fieldNameVal,fieldTextVal){
eval("document.Forms[0]." + fieldNameVal + ".value =" + fieldTextVal)
}
</Script>

Rob B
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Don't see the error here



eval("document.F<------ try an 'f'

Never mind, junk the whole thing....

document.forms[0].elements[fieldNameVal].value = fieldTextVal;


*** Sent via Developersdex http://www.developersdex.com ***
Lee
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Don't see the error here


Fetty said:[color=blue]
>
><script language="JavaScript">
>function copyComment(fieldNameVal,fieldTextVal){
>eval("document.Forms[0]." + fieldNameVal + ".value =" + fieldTextVal)
>}
></Script>[/color]


1. language="Javascript" is deprecated.
2. Don't use eval() to reference form fields.
3. There is no document.Forms attribute. It's "document.forms".


Try:

<script type="text/javascript">
function copyComment(fieldNameVal,fieldTextVal){
document.forms[0].elements[fieldNameVal].value = fieldTextVal;
}
</script>

Grant Wagner
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Don't see the error here


"Fetty" <davef@helixpoint.com> wrote in message
news:1113232255.149284.214090@f14g2000cwb.googlegr oups.com...[color=blue]
> <script language="JavaScript">
> function copyComment(fieldNameVal,fieldTextVal){
> eval("document.Forms[0]." + fieldNameVal + ".value =" + fieldTextVal)
> }
> </Script>[/color]

script tag language attribute deprecated, type attribute required.
eval() not required. JavaScript is case-sensitive and the forms
collection of the document object is lowercase.

<script type="text/javascript">
function copyComment(fieldNameVal, fieldTextVal)
{
document.forms[0].elements[fieldNameVal].value = fieldTextVal;
}
</script>

--
Grant Wagner <gwagner@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq


Closed Thread