Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-01-2005, 04:36 PM   PM User | #1
padraigosca
New to the CF scene

 
Join Date: Jun 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padraigosca is an unknown quantity at this point
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();
}
padraigosca is offline   Reply With Quote
Old 06-01-2005, 05:15 PM   PM User | #2
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
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.
Mr J is offline   Reply With Quote
Old 06-01-2005, 05:27 PM   PM User | #3
padraigosca
New to the CF scene

 
Join Date: Jun 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padraigosca is an unknown quantity at this point
Works perfectly now. Thanks for your help.
padraigosca is offline   Reply With Quote
Old 06-02-2005, 04:32 AM   PM User | #4
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
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.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 06-02-2005, 10:39 AM   PM User | #5
padraigosca
New to the CF scene

 
Join Date: Jun 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
padraigosca is an unknown quantity at this point
Excellent link, explained exactly what i needed to know. Have a few more ideas for my site now so thanks.
padraigosca is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:28 AM.


Advertisement
Log in to turn off these ads.