Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not an object error 1

Status
Not open for further replies.

mickeyg

Technical User
Mar 30, 2001
120
US
I have a button that I want to click to copy a line to another line. Since all the fieldnames are the same except for the ending number(1-5), I want to pass the number to the function and build the syntax.

For example, if copyfrom = 1 and copyto = 2 then
my syntax should say document.fishform.weight2 = document.fishform.weight1;

This is my code so far:
<INPUT TYPE=&quot;button&quot; value=&quot;Copy&quot; onClick=&quot;CopyLine(document.fishform.copyfrom.value, document.fishform.copyto.value)&quot;>
Line # <INPUT TYPE=&quot;text&quot; NAME=&quot;copyfrom&quot; SIZE=&quot;1&quot; MAXLENGTH=&quot;1&quot; VALUE=&quot;1&quot; onBlur=&quot;ValidLineNum(this)&quot;>
to Line #<INPUT TYPE=&quot;text&quot; NAME=&quot;copyto&quot; SIZE=&quot;1&quot; MAXLENGTH=&quot;1&quot; VALUE=&quot;2&quot; onBlur=&quot;ValidLineNum(this)&quot;>
<BR><BR>

function CopyLine(FromLine, ToLine) {
var myForm = document.fishform;

myForm.lweight[ToLine] = myForm.lweight[FromLine];
myForm.lcategory[ToLine] = myForm.lweight[FromLine];
}

Thank you for your assistance,
Mickey
 
I think I know the answer but I have not tried it.
The solution is to work with &quot;eval&quot;:

Change your function to:

function CopyLine(FromLine, ToLine) {
   var myForm = document.fishform;
var S;
S =  &quot;myForm.lweight&quot; + ToLine + &quot;=myForm.lweight&quot; + FromLine;
eval(S);

}

Do the same with your category-line.
What happens is that you build a string hosting the command that you have put together from the inputs.
Then execute it with eval! Let me know if this worked.
 
I changed my code to the following:
var myAssign;
myAssign = eval(&quot;document.fishform.lweight&quot; + ToLine + &quot; = document.fishform.lweight&quot; + ToLine);

However, I receive the &quot;Object does not support this method or property&quot; error message.

Thanks,
Mickey
 
Try it this way:
Code:
var toline = eval(&quot;document.fishform.lweight&quot;+ToLine);
var fromline = eval(&quot;document.fishform.lweight&quot;+FromLine);
toline.value = fromline.value;

Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Try taking this line:
Code:
NewWeight.Value = OriginalWeight.Value;
and making &quot;value&quot; all lower case.

That's the only thing I could see with a quick look.

Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Try this:

[tt]<SCRIPT LANGUAGE=&quot;Javascript&quot;>
[COLOR=666666]<!--[/color]

function copyLine(theform, fromLine, toLine){
var vField = &quot;lweight&quot;;
theform
Code:
[
vField + toLine.value
Code:
]
.value = theform
Code:
[
vField + fromLine.value
Code:
]
.value;
}

[COLOR=666666]//-->[/color]
</SCRIPT>[/tt]

[tt][COLOR=000080][tt][COLOR=FA5000]<FORM NAME=&quot;fishform&quot;>[/color][/tt][/color][/tt]
[tt][COLOR=000080][tt][COLOR=FA5000]<INPUT TYPE=&quot;button&quot; value=&quot;Copy&quot;
onClick=&quot;copyLine(this.form, this.form.copyfrom, this.form.copyto)&quot;>[/color][/tt][/color][/tt]Line #
[tt][COLOR=000080][tt][COLOR=FA5000]<INPUT TYPE=&quot;text&quot; NAME=&quot;copyfrom&quot; SIZE=&quot;1&quot; MAXLENGTH=&quot;1&quot; VALUE=&quot;1&quot; onBlur=&quot;ValidLineNum(this)&quot;>[/color][/tt][/color][/tt]to Line #
[tt][COLOR=000080][tt][COLOR=FA5000]<INPUT TYPE=&quot;text&quot; NAME=&quot;copyto&quot; SIZE=&quot;1&quot; MAXLENGTH=&quot;1&quot; VALUE=&quot;2&quot; onBlur=&quot;ValidLineNum(this)&quot;>[/color][/tt][/color][/tt][tt][COLOR=000080]<BR>[/color][/tt]
[tt][COLOR=000080][tt][COLOR=FA5000]</FORM>[/color][/tt][/color][/tt] - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top