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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RADIO BUTTONS SELECTING 2 DIFFERENT FILES??

Status
Not open for further replies.

giggles7840

IS-IT--Management
Mar 8, 2002
219
US
This should be really easy but im not finding the answer.

I have 2 jsp pages.one which gets parameters and the second is the firing page. i have added radio buttons to the parameter page. in the firing page i need it to determine:
if radio1 is selected then open test1.rpt.
if radio2 is selcted then open test2.rpt.

See codes below. Thanks for your help...

Parameter JSP
<HTML>
<HEAD>
<TITLE>test</TITLE>
<link rel=&quot;stylesheet&quot; href=&quot;rportal-main.css&quot;>
</HEAD>
<BODY>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;>
<tr>
<td class=&quot;portlettitlebox&quot; align=&quot;left&quot; valign=&quot;top&quot;>
<div align=&quot;right&quot;>Cost Center Report </div>
</td>
</tr>
</table>
<br>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;test2fire.jsp&quot;>
<p><u><b>Select a type of report:</u></b></p>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;3&quot; cellpadding=&quot;3&quot;>

<input type=&quot;radio&quot; name=&quot;prompt0&quot; value=&quot;radio1&quot; checked>Crystal Report<br>

<input type=&quot;radio&quot; name=&quot;prompt0&quot; value=&quot;radio2&quot;>Excel Export<br>
<tr>
<td width=&quot;50%&quot;>
<div align=&quot;right&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</div>
</td>
<td>
<div align=&quot;left&quot;>
<input type=&quot;reset&quot; name=&quot;Reset&quot; value=&quot;Reset&quot;>
</div>
</td>
</tr>
</table>
</form>
<p> </p>
</BODY>
</HTML>

Fire JSP
<!-- Version 1.00 - 01/28/2002 11:04 -->
<%@ page language=&quot;java&quot; %>
<%@ page import=&quot;com.maincontrol.rp.admin.*&quot; %>
<%@ page import=&quot;com.maincontrol.rp.beans.*&quot; %>
<%@ page import=&quot;com.maincontrol.rp.query.*&quot; %>
<%@ page import=&quot;java.lang.*&quot; %>
<%@ page import=&quot;java.util.*&quot; %>

<%@ taglib uri=&quot;/WEB-INF/struts-bean.tld&quot; prefix=&quot;bean&quot; %>
<%@ taglib uri=&quot;/WEB-INF/struts-html.tld&quot; prefix=&quot;html&quot; %>

<%@ include file=&quot;FireFragmentA.lssi&quot; %>

<title>Test Report</title>

<%@ include file=&quot;FireFragmentB.lssi&quot; %>

<%
String prompt0 = (String)request.getParameter(&quot;prompt0&quot;);
String table = &quot;KOMP&quot;;
String view = &quot;C_Rep_Test&quot;;
%>

<%@ include file=&quot;FireFragmentC.lssi&quot; %>

***************************************************
this is where i think the if then should go, i just dont know how to write it.
****************************************************
if (Radio1.Checked)
<form name=&quot;forma&quot; method=&quot;post&quot; action=&quot;<%= url %>test1.rpt&quot; target=&quot;crview&quot;>;
else if (Radio2.Checked)
<form name=&quot;forma&quot; method=&quot;post&quot; action=&quot;<%= url %>test2.rpt&quot; target=&quot;crview&quot;>;

<input type=&quot;hidden&quot; name=&quot;prompt0&quot; value=&quot;<%= prompt0 %>&quot;>

*****************************************************

<%@ include file=&quot;FireFragmentD.lssi&quot; %>

<%@ include file=&quot;FireFragmentE.lssi&quot; %>

 
ok, i have been playing around with the if/then else/ part. its still not working but now i have this....whats wrong with this thing. it should work!!!

<%
String prompt0 = (String)request.getParameter(&quot;prompt0&quot;);
String table = &quot;KOMP&quot;;
String view = &quot;C_Rep_Test&quot;;
%>

<%@ include file=&quot;FireFragmentC.lssi&quot; %>


if (prompt0 == &quot;radio1&quot;)
{
alert(&quot;Welcome! I'm so glad you came! Please, read on!&quot;);
}
else
{
window.open(&quot;<%= url %>test2.rpt&quot; target=&quot;crview&quot;>;
}
 
giggles,
I am not a JS programmer, but I did find a thread in the javascript forum that appears to have your answer.
here is the thread javascript:eek:penindex(450,350,'I did a keyword search in that forum for &quot;Radio&quot;
If I read the post correctly, it is basically saying to add a unique ID parameter and value parameter to each of your radio buttons . so it would look like this:

<input type=&quot;radio&quot; name=&quot;prompt0&quot; value=&quot;radio1&quot; id=&quot;loc1&quot; value = &quot;1&quot; checked>Crystal Report<br>
<input type=&quot;radio&quot; name=&quot;prompt0&quot; value=&quot;radio2&quot; id=&quot;loc2&quot; value = 2 >Excel Export<br>
To access each element of the control group use this:
document.getElementById(&quot;id&quot;).checked

I am guessing that you could use the return of that function in an IF ... Then structure to do what you need.
Perhaps like this,

If document.getElementById(&quot;id&quot;).checked = &quot;loc1&quot; Then
<form name=&quot;forma&quot; method=&quot;post&quot; action=&quot;<%= url %>test1.rpt&quot; target=&quot;crview&quot;>;
else if document.getElementById(&quot;id&quot;).checked = &quot;loc2&quot;
<form name=&quot;forma&quot; method=&quot;post&quot; action=&quot;<%= url %>test2.rpt&quot; target=&quot;crview&quot;>;
End If
*I dont know in JS if statements require an end if

Let me know if this helps
Michael
 
ok, then why wouldnt you be able to use the prorpeties that are already identified....

if (prompt0 == &quot;radio1&quot;)
{
<form name=&quot;forma&quot; method=&quot;post&quot; action=&quot;<%= url %>test1.rpt&quot; target=&quot;crview&quot;>;
<input type=&quot;hidden&quot; name=&quot;prompt0&quot; value=&quot;<%= prompt0 %>&quot;>;
}
else
{
if ((prompt0 == &quot;radio2&quot;) )
}
<form name=&quot;forma&quot; method=&quot;post&quot; action=&quot;<%= url %>test2.rpt&quot; target=&quot;crview&quot;>;
<input type=&quot;hidden&quot; name=&quot;prompt0&quot; value=&quot;<%= prompt0 %>&quot;>;
{
 
giggles,
as I said, I am not a JS programmer, so I really cannot answer that. I just saw that thread, and thought I would attempt to atleast help you out a little
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top