...

View Full Version : Form properties problem



cathay65
03-12-2004, 10:44 AM
hi, every one i have a problem hope you guys can help me.
i were using a form with text box that allow user to key in how many text box they want, after that i will collect data from the text box. The text box is depent on user so can i do as follow:

eg.

(as c=5)

function cal(c)
{
var num;
num = frmname.typename + c + .value;
}
<< can it run like this >>

previously we will write as this:
function cal()
{
var num;
num = frmname.typename5.value;
}
<< or only run this >>


this will change when user want to.....
<input type=text name=typename1>
<input type=text name=typename2>
<input type=text name=typename3>
<input type=text name=typename4>
<input type=text name=typename5>
<input type=text name=typename6>

homerUK
03-12-2004, 11:16 AM
I'm a bit confused what it is you are asking us to do? :confused:

could you clarify a little please?

Kor
03-12-2004, 01:01 PM
if you want to pass a parameter to add it in a name's or id's string, use

if name in form

function cal(c)
{
var num;
num = document.frmname.elements['typename' + c] .value;
}

or, if id

function cal(c)
{
var num;
num = document.getElementById('typename' + c) .value;
}

cathay65
03-13-2004, 03:10 AM
HI, is me again i just want to say thanks to Kor, because it really work so i don need to think other menthod to solve it, and also thanks to homerUK, the answer i have get it from Kor but i hope next time i will get from u, homerUK. Thanks to the friend who help me.

Kor
03-15-2004, 08:44 AM
:thumbsup:

You must have forgot that the general reference for forms inner is:

document.forms[name_or_order].elements[name_or_order].attribute

the ref

document.form-name.element_name.attribute is only a "short cut" and does not permit you to modify dinamically the object's referenece.

Good luck in future programming :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum