...

View Full Version : Javascript trouble



padraigosca
06-01-2005, 05:36 PM
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();
}

Mr J
06-01-2005, 06:15 PM
Please try the following



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();
}

padraigosca
06-01-2005, 06:27 PM
Works perfectly now. Thanks for your help. :thumbsup:

glenngv
06-02-2005, 05:32 AM
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.

padraigosca
06-02-2005, 11:39 AM
Excellent link, explained exactly what i needed to know. Have a few more ideas for my site now so thanks. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum