/    Sign up×
Community /Pin to ProfileBookmark

Syntax help please

Hello

I hope someone can put me on track to see this through.
The form below, I have stripped everything out of except the points of interest for my syntax challenge.

[CODE]
<form name=”products_{pb_id}” action=”{product_details_href}” method=”post”>
<input type=”hidden” id=”pb_id” name=”pb_id” value=”{pb_id}” />
<input type=”hidden” id=”myitem_id” name=”myitem_id” value=”{item_id}” />
</form>
[/CODE]

I have created a popup to retrieve certain field values in which it functioned perfectly as I need providing I hard set the form name, products_974 (which in the test the “pb_id” value above is 974)

[CODE]<script type=”text/javascript”>
window.onload = function(){
var pw = window.opener;
if(pw){
var inputFrm = pw.document.forms[‘products_974’];
var outputFrm = document.forms[‘main’];
outputFrm.elements[‘size’].value = inputFrm.elements[‘item_idelso’].value;
}
}
</script>[/CODE]

What I am trying to do is bring the “pb_id” value from the parent so I can do something like this

[CODE]
<script type=”text/javascript”>
window.onload = function(){
var pw = window.opener;
if(pw){
var FormNameID = pw.document.getElementById(‘pb_id’);
var inputFrm = pw.document.forms[‘products_’+FormNameID];
var outputFrm = document.forms[‘main’];
outputFrm.elements[‘size’].value = inputFrm.elements[‘item_idelso’].value;
}
}
</script>
[/CODE]

I am not fluent with Javascript and work a lot on “trial & error” but I have run out of the “trials” to try and would like to get some direction on how I can make this happen.

Thank you

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Elso 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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