Forum Moderators: open
i am working on a popup script that processes some text entry to write back to a DB file. the particular field that gets updated is dependent upon the particular form submitted by the popup's window.opener.
there are 12 unique forms (correlating with the 12 fields in the DB) on the window.opener. but, they may all be modified by the same popup.
however, i'm having difficulty figuring out how to tell the popup which form was submitted.
at the beginning of the popup i define some variables like:
var BR4 = window.opener.formname.BR3.value;
but 'formname' needs to be the actual name of the form in the window.opener. i'm having trouble A) figuring out how to get the window.opener to pass that information. and B) getting my var BR (for example) to accept the variable in that declaration.
var BR4 = window.opener."+formname+".BR3.value;
for example, does not work.
is there a basic technique here for doing this? thanks.
FYI, i dont think i have the tools (or knowledge) to do serverside JavaScripting. so, i just declare an ASP session variable inside each form i'm submitting like:
<input type="hidden" name ="whatever" value="<%Session("FORMNAME")="the_name_of_this_particular_form"%>
then, in the popup i can query it with:
var BR4=window.opener.<%=Session("FORMNAME")%>.BR3.value;
works like a champ!
my brilliant idea had a fatal flaw: the ASP i wrote ignored the HTML it was embedded in. (seemed like a good idea at the time--i'll call it caffeine deprivation)
well, here is some code to illustrate exactly where i'm having trouble. if anyone can help again, i'd appreciate it.
initially i present a page of form elements via ASP that display as buttons. there are 12 different forms similar to below, with the exception that they all have different form names to modify different fields of the DB--the field 'Photo' in the case below.
<form name="photoform" method="post" action="popup.asp" onsubmit="showpopup(); return false">
<INPUT Type="hidden" Name="BR3" Value="<%=(maintbr2)%>">
<INPUT Type="hidden" Name="SC2" Value="<%=(maintsc)%>">
<INPUT Type="hidden" Name="FM" Value="<%=mySQL("family")%>">
<INPUT Type="hidden" Name="field" Value=Photo>
<INPUT Type="submit" onClick="showPopup()" value="Edit photo for <%=mySQL("family")%>">
</FORM>
as you can see from above, clicking on a button opens a popup. the popup has a text field that will write its contents back to the DB.
my problem is that i need to pass the name of the form clicked in the code above to the popup so that i can create a variable in the popup to query the proper form's hidden data:
var BR4 = window.opener.VARIABLE.BR3.value;
var SC3 = window.opener.VARIABLE.SC2.value;
where VARIABLE is the name of the form submitted in the window.opener
this is where my limited experience comes in. i really have no idea of how to accomplish this.
i've pondered on this a while and come up with a couple of unworking ideas. for example, one thought was to add a session variable to the ASP and assign it in the form that gets submitted.
<INPUT Type="hidden" value="<%Session("FORMNAME")="photoform"%>">
but, that doesnt work. the ASP parser ignores this html version of a CASE variable and assigns the variable every time it sees it. so, the last assignment on the page is the value (the name of the 12th form).