Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form properties problem

    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>

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    I'm a bit confused what it is you are asking us to do?

    could you clarify a little please?

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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;
    }
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    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.

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Thumbs up



    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
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •