Forum Moderators: open

Message Too Old, No Replies

concatination problem

         

tommy1980

11:12 am on Jan 6, 2005 (gmt 0)

10+ Year Member



The problem that I am having is concatinating a value to a string and then passing it into a path so that I can remove a value from just one text box.

The code that I am using to do this is below:

function clearTask(lngLineNo)
{
var i = "InputName" + lngLineNo

document.FormName.InputName+i.value = "";
return false
}

If any one could help it would be much appreciated.

Bernard Marx

1:19 pm on Jan 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The info isn't 100%, so I'm making assumptions here, but assuming that you have form inputs, named:

someName1
someName2
etc

then your problem isn't so much concatenation (although it's involved) but building a reference chain from arbitrary input. Here's how I think it'll work for you:


function clearTask(lngLineNo)
{
document.FormName['someName'+lngLineNo].value = "";
return false
}

adni18

1:27 pm on Jan 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here would be an optional script that would do the same job:

function clearTask(lngLineNo) {
eval("document.FormName.someName"+lngLineNo).value = "";
return false }

tommy1980

4:28 pm on Jan 6, 2005 (gmt 0)

10+ Year Member



Bernard Marx, cheers mate.

That is working perfectly.

And yes you assumed right about the input type fields