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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2003
    Location
    upper midwest
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using the URL to control the # of textboxes

    how can I change this code to have the URL link from the previos page control the nuber of textboxes? the sample Url is http://www.server.com/firstpage.html?Nmtxtbxs=5
    If Nmtxtbx=5 then I want there to be

    if(f.result5.value=="result5" && f.result4.value != "result4")
    {f.result5.value = f.item_name.value;}
    if(f.result4.value=="result4" && f.result3.value != "result3")
    {f.result4.value = f.item_name.value;}
    if(f.result3.value=="result3" && f.result2.value != "result2")
    {f.result3.value = f.item_name.value;}
    if(f.result2.value=="result2" && f.result1.value != "result1")
    {f.result2.value = f.item_name.value;}
    if(f.result1.value=="result1")
    {f.result1.value = f.item_name.value;}

    And if Nmtxtbx=2 then I want there to be

    if(f.result2.value=="result2" && f.result1.value != "result1")
    {f.result2.value = f.item_name.value;}
    if(f.result1.value=="result1")
    {f.result1.value = f.item_name.value;}

    the code that I am using for each of the pages is this.

    function moveData(f){
    if(f.item_name.value != "total"){
    if(f.result3.value=="result3" && f.result2.value != "result2")
    {f.result3.value = f.item_name.value;}
    if(f.result2.value=="result2" && f.result1.value != "result1")
    {f.result2.value = f.item_name.value;}
    if(f.result1.value=="result1")
    {f.result1.value = f.item_name.value;}
    }
    for(m=0; m<f.elements.length; m++){
    if(f.elements[m].type == "checkbox" || f.elements[m].type == "radio" && f.elements[m].checked){
    f.elements[m].checked=false;
    } }
    f.item_1.value="";
    f.item_2.value="";
    f.item_name.value="";
    }

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Either you dynamically write the code, or you loop through the form array elements instead of writing 5+ if statments.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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