/    Sign up×
Community /Pin to ProfileBookmark

problems with passing data from one window to another

I have been having problems with passing data from one window to another. I can get the data to pass correctly if I change the name attribute in verse.php and the changing product_info.php to match it but for some reason it will not if I use the naming scheme id[prefix_number]. I cannot change verse.php as it will throw the rest of my site off. Is there any way to correct product_info.php to send the data correctly?

These are the important parts of the files in question.

[B]product_info.php[/B]

[CODE]<SCRIPT LANGUAGE=”JavaScript”>

<!– Begin

function sendValue(s){
var selvalue = s.options[s.selectedIndex].value;
window.opener.document.cart_quantity.id[txt_61].value = selvalue;
window.close();
}
// End –>
</script>
</head>

<body>

<center>
<form name=selectform>
<select name=selectmenu size=”8″>
<option value=”Item A”>Item A
<option value=”Item B”>Item B
<option value=”Item C”>Item C
<option value=”Item D”>Item D
<option value=”Item E”>Item E
<option value=”Item F”>Item F
<option value=”Item G”>Item G
<option value=”Item H”>Item H
<option value=”Item I”>Item I
<option value=”Item J”>Item J
<option value=”Item K”>Item K
<option value=”Item L”>Item L
<option value=”Item M”>Item M
<option value=”Item M”>Item N
<option value=”Item O”>Item O
<option value=”Item P”>Item P
<option value=”Item Q”>Item Q
<option value=”Item R”>Item R
<option value=”Item S”>Item S
<option value=”Item T”>Item T
<option value=”Item U”>Item U
<option value=”Item V”>Item V
<option value=”Item W”>Item W
<option value=”Item X”>Item X
<option value=”Item Y”>Item Y
<option value=”Item Z”>Item Z
</select>
<p>
<input type=button value=”Item Select Item” onClick=”sendValue(this.form.selectmenu);”>
</form>[/CODE]

[B]verse.php[/B]

[CODE]<input type=”text” name=”id[txt_61]” size=”32″ maxlength=”32″ value=””>[/CODE]

Any ideas would be great, thanks!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterApr 13.2005 — The name: [color=royalblue]id[text_61][/color] is not an array...

You need to be careful not to trick JavaScript into thinking that it is an array.
<i>
</i>window.opener.document.cart_quantity["id[txt_61]"].value= selvalue;
Copy linkTweet thisAlerts:
@forbushblauthorApr 14.2005 — Thanks, that fixed my problem! I thought it might be looking for an array but I didn't know how to make javascript look at it as a literal name.

One more question, what if I would like to send more than one line from verse.php to more than one line in product_info.php using the one submit button. Can I just modify the function sendValue(s)? If so, how do I do it? I know that it is probably really simple but I am not a javascript guru. I work mainly with PHP. Thanks again!
Copy linkTweet thisAlerts:
@UltimaterApr 14.2005 — Why not send it as an array?
<i>
</i>var thisArray=[0,1,2,3]
window.opener.myArray=thisArray
×

Success!

Help @forbushbl spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...