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

Thread: function help

  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,474
    Thanks
    15
    Thanked 0 Times in 0 Posts

    function help

    can someone help me with teh following function I am trying to write.

    my code:

    function PaymentsDelete(i){
    if(document.payments.deleteme.checked){
    alert('delete');
    myfield=amount+i;
    documents.payments.myfield.value=0;
    }
    }

    What I want this to do is to take the i passed in and set the field in the payments form name amount and i to 0.
    In other words if i is 1 then the script should set payments.amount1=0.

    can someone help me get this working. Now it seems to be ignoring the statement.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    You may just have missed a typo in this line

    documents.payments.myfield.value=0;

    remove the s from documents to give you

    document.payments.myfield.value=0;
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,474
    Thanks
    15
    Thanked 0 Times in 0 Posts
    thanks - but it's still not working.
    is that the right way to access it setting myfield to the field name and doing document.payments.myfield??

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Try it this way

    PHP Code:
    function PaymentsDelete(i){
    if(
    document.payments.deleteme.checked){
    alert('delete');
    myfield="amount"+i;
    document.payments[myfield].value=0;
    }

    or this way depending on your preference


    PHP Code:
    function PaymentsDelete(i){

    myForm=document.forms["payments"]

    if(
    myForm["deleteme"].checked){
    myForm["amount"+i].value=0;
    }


    Last edited by Mr J; 09-03-2006 at 10:57 AM.
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #5
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    err what type hase the control "deleteme". A checkbox? If so, I guess that you have a collection of checkboxes with the same name. In this case you should circle through the collection or use the index. Can we see your HTML code?
    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
    •