Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access variable thru pop-up from JSP statement (case 2) 1

Status
Not open for further replies.

dove85

MIS
Aug 8, 2001
19
US
A form object "vendor_id" is passed to a pop-up window thru a JavaScript function. I retrieved the value of the passed object in the pop-up window fine, but failed to put the var into a JSP statement.

Your input would be appreciated.

======================================================================
The JSP with the JavaScript function (partial):

<HTML>
<HEAD>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function PopUpWindow() {
showModalDialog('called.jsp',InvForm.vendor_id.value,'status:No;help:No;resizable:Yes;dialogWidth:690px;dialogHeight:200px;dialogLeft=220px;dialogTop=375px');
}
</SCRIPT>

</HEAD>
<BODY>
<FORM NAME=&quot;InvForm&quot; METHOD=&quot;post&quot; ACTION=&quot;doSUBMIT.jsp&quot;>
.
.
<TABLE>
<TR>
<TD>
<INPUT TYPE=&quot;text&quot; NAME=&quot;inv_no&quot; SIZE=&quot;15&quot;>
<A HREF=&quot;#&quot; onClick=&quot;PopUpWindow()&quot;><IMG SRC=&quot;/webapp/images/LOV.gif&quot; BORDER=0 ALIGN=absmiddle></A>
</TD>
<TD><INPUT TYPE=&quot;hidden&quot; NAME=&quot;vendor_id&quot; SIZE=&quot;20&quot;></TD>
</TR>
.
.
<TABLE>
<input type=&quot;Submit&quot; NAME=&quot;save&quot; value=&quot;SAVE&quot;>
</FORM>
</BODY>
</HTML>

======================================================================
called.jsp: the &quot;vendor_id&quot; is correctly passed and has been put into an object (&quot;vendor_id&quot;)in the form. How to put &quot;vendor_id&quot; in a JSP statement so that its value can be passed to a JavaBean? The statement <% xvendor_id = request.getParameter(&quot;vendor_id&quot;); %> does not work since &quot;vendor_id&quot; didn't get here thru the POST method.

<HTML>
<HEAD>
<SCRIPT>
window.onload=fnInit;
function fnInit()
{
oVendorId.innerHTML=dialogArguments;
document.InvoiceForm.vendor_id.value = oVendorId.innerHTML;
}
</SCRIPT>
</HEAD>
<BODY>
<H4>Invoice List for Vendor Id <SPAN ID=&quot;oVendorId&quot;></SPAN></H4>
<FORM NAME=&quot;InvoiceForm&quot; METHOD=&quot;post&quot; ACTION=&quot;WindowClose.jsp&quot;>
<TABLE>

<%! String xvendor_id; %>
<% xvendor_id = request.getParameter(&quot;vendor_id&quot;); %>
<% if (xvendor_id != null) { %>
<% util.connect(); %>
<% String[] [] invoice = select.getInvInfo(xvendor_id); %>
.
.
<% }%>

<TR><TD><SPAN><INPUT TYPE=&quot;hidden&quot; NAME=&quot;vendor_id&quot;></SPAN></TD></TR>
</TABLE>

</FORM>
</BODY>
</HTML>
 
I am not sure how this is much different than before but try this:
YOUR CODE (my additions are in bold)

A form object &quot;vendor_id&quot; is passed to a pop-up window thru a JavaScript function. I retrieved the value of the passed object in the pop-up window fine, but failed to put the var into a JSP statement.

Your input would be appreciated.

======================================================================
The JSP with the JavaScript function (partial):

<HTML>
<HEAD>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function PopUpWindow() {
var url = &quot;control.jsp?vendor_id=&quot; + document.forms[&quot;InvForm&quot;].elements[&quot;vendor_id&quot;].value;
showModalDialog(url,InvForm.vendor_id.value,'status:No;help:No;resizable:Yes;dialogWidth:690px;dialogHeight:200px;dialogLeft=220px;dialogTop=375px');
}
</SCRIPT>

</HEAD>
<BODY>
<FORM NAME=&quot;InvForm&quot; METHOD=&quot;post&quot; ACTION=&quot;doSUBMIT.jsp&quot;>
.
.
<TABLE>
<TR>
<TD>
<INPUT TYPE=&quot;text&quot; NAME=&quot;inv_no&quot; SIZE=&quot;15&quot;>
<A HREF=&quot;#&quot; onClick=&quot;PopUpWindow()&quot;><IMG SRC=&quot;/webapp/images/LOV.gif&quot; BORDER=0 ALIGN=absmiddle></A>
</TD>
<TD><INPUT TYPE=&quot;hidden&quot; NAME=&quot;vendor_id&quot; SIZE=&quot;20&quot;></TD>
</TR>
.
.
<TABLE>
<input type=&quot;Submit&quot; NAME=&quot;save&quot; value=&quot;SAVE&quot;>
</FORM>
</BODY>
</HTML>

======================================================================
called.jsp: the &quot;vendor_id&quot; is correctly passed and has been put into an object (&quot;vendor_id&quot;)in the form. How to put &quot;vendor_id&quot; in a JSP statement so that its value can be passed to a JavaBean? The statement <% xvendor_id = request.getParameter(&quot;vendor_id&quot;); %> does not work since &quot;vendor_id&quot; didn't get here thru the POST method.

<HTML>
<HEAD>
<SCRIPT>
window.onload=fnInit;
function fnInit()
{
oVendorId.innerHTML=dialogArguments;
document.InvoiceForm.vendor_id.value = oVendorId.innerHTML;
}
</SCRIPT>
</HEAD>
<BODY>
<H4>Invoice List for Vendor Id <SPAN ID=&quot;oVendorId&quot;></SPAN></H4>
<FORM NAME=&quot;InvoiceForm&quot; METHOD=&quot;post&quot; ACTION=&quot;WindowClose.jsp&quot;>
<TABLE>

<%! String xvendor_id; %>
<% xvendor_id = request.getParameter(&quot;vendor_id&quot;); %>
<% if (xvendor_id != null) { %>
<% util.connect(); %>
<% String[] [] invoice = select.getInvInfo(xvendor_id); %>
.
.
<% }%>

<TR><TD><SPAN><INPUT TYPE=&quot;hidden&quot; NAME=&quot;vendor_id&quot;></SPAN></TD></TR>
</TABLE>

</FORM>
</BODY>
</HTML>
Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top