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
    Jun 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript trouble

    Hi,
    I would not say that i am a fan of javascript but I do need to use it this time around and i've been looking at this too long so i cant figure it out.
    What i have is a parent window that is being passed a value from the child window.. the child window is seaching a database and returning the value the user clicks on. So far so good..
    Where i am having difficulty is when i pass the selected count variable to the function i dont know how to make the "X" be equal to the count value..
    ie. if count = 2,
    var txtVal = document.formPop.name2.value;
    var txtVal1 =document.formPop.id2.value;


    function SendInfo(count){
    var txtVal = document.formPop.nameX.value;
    var txtVal1 = document.formPop.idX.value;
    window.opener.document.form.customer_name.value = txtVal
    window.opener.document.form.customer_id.value = txtVal1
    window.close();
    }

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Please try the following


    PHP Code:
    function SendInfo(count){
    var 
    txtVal document.forms["formPop"]["name"+count].value;
    var 
    txtVal1 document.forms["formPop"]["id"+count].value;

    window.opener.document.form.customer_name.value txtVal
    window
    .opener.document.form.customer_id.value txtVal1
    window
    .close();

    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
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Works perfectly now. Thanks for your help.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,032
    Thanks
    0
    Thanked 248 Times in 245 Posts
    What Mr J showed you is a combination of dot notation with square bracket notation. Using square bracket notation is more powerful and flexible. You can see more info on it in my sig.

  • #5
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excellent link, explained exactly what i needed to know. Have a few more ideas for my site now so thanks.


  •  

    Posting Permissions

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