RSS Forums RSS
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 2712 | Replies: 2
Reply
Join Date: Jan 2007
Posts: 6
Reputation: sandeep0708 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sandeep0708 sandeep0708 is offline Offline
Newbie Poster

new to javascript

  #1  
Mar 26th, 2007
Hi all,

I have a simple problem but a major 1 for me now...
i need to pass the selected value of radio button from 1 jsp to another jsp i.e when user selects a radio button option and then clicks on the submit button then the selected value should b passed to another jsp and should b able to display it....
plz help me out ......
ne sample code will b highly beneficial......
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Rep Power: 5
Solved Threads: 34
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: new to javascript

  #2  
Mar 26th, 2007
JavaScript != JSP
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote  
Join Date: Feb 2007
Posts: 14
Reputation: Thendral is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Thendral Thendral is offline Offline
Newbie Poster

Re: new to javascript

  #3  
Apr 2nd, 2007
Originally Posted by sandeep0708 View Post
Hi all,

I have a simple problem but a major 1 for me now...
i need to pass the selected value of radio button from 1 jsp to another jsp i.e when user selects a radio button option and then clicks on the submit button then the selected value should b passed to another jsp and should b able to display it....
plz help me out ......
ne sample code will b highly beneficial......




Hai Sandeep,

I guess the following code is the answer for your question.

I have two jsp files. one is test1.jsp and another is test2.jsp.
i have radio buttons in test1.jsp file and i am trying to print the valur of radio button in test2.jsp.

test1.jsp

<%@page import = "java.io.*, java.util.*,java.text.*"%>
<html>
<head>
<script language="javascript1.1">
function validate()
{
f=document.forms[0];
alert("validate Starts");
for(var i=0;i<5;i++) {
if(f.radiobutton[i].checked) {
f.hide.value=f.radiobutton[i].value;
alert("value stored");
}
}
f.hiddenField.value="one";
return;
}
</script>
<title>Test</title>
</head>
<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form name="form1" method="post" action="test2.jsp">
<p>
<label>
<input name="radiobutton" type="radio" value="one">
One
</label>
<br>
<label>
<input name="radiobutton" type="radio" value="two">
Two
</label>
<br>
<label>
<input name="radiobutton" type="radio" value="three">
Three</label>
<br>
<label>
<input name="radiobutton" type="radio" value="four">
Four
</label>
<br>
<label>
<input name="radiobutton" type="radio" value="five">
Five
</label>
<br>
</p>
<p>
<input name="submit" type="submit" id="submit" onclick="validate()" value="Submit">
</p>
<p>
<input name="hide" type="hidden" id="hide">
<input type="hidden" name="hiddenField">
</p>
</form>
<p>&nbsp;</p>
</body>
</html>


Test2.jsp

<%@page import="java.sql.*,java.util.*"%>
<%@ page import ="java.util.regex.Pattern, common.Util"%>
<%
String hide=null;
String hide1=null;
if(request.getParameter("hide")!=null)
hide=request.getParameter("hide");
if(request.getParameter("hiddenField")!=null)
hide1=request.getParameter("hiddenField");
%>
<html>
<head>
<title>Test2</title>
</head>
<body>
<form name="form1" method="post">
<input type="text" name="textfield" value="<%=hide%>">
<input type="text" name="textfield" value="<%=hide1%>">
</form>
</body>
</html>


hope so you understand.
Bye...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:02 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC