new to javascript

Reply

Join Date: Jan 2007
Posts: 6
Reputation: sandeep0708 is an unknown quantity at this point 
Solved Threads: 0
sandeep0708 sandeep0708 is offline Offline
Newbie Poster

new to javascript

 
0
  #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......
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: new to javascript

 
0
  #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 Quick reply to this message  
Join Date: Feb 2007
Posts: 14
Reputation: Thendral is an unknown quantity at this point 
Solved Threads: 0
Thendral Thendral is offline Offline
Newbie Poster

Re: new to javascript

 
0
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JSP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC