Hi,
I am creating a web application. In that I have multiple radio button and two button.
What I want to do is--
I want to choose a radio button and according to that value if I will click the button1, I want to display a different jsp page.
But I don't know how to do that, because I am using a form in the jsp page and i set the type property for the from as type="newjsp.jsp". It displaying me the newjsp, when i click that button
But how can I work with the next button, if I want to display some different jsp page after clicking that button

I want to do something like this.

If radiobut1.checked then

at click of button1

display jspnew.jsp

else

if radio2.checked then

at click of button1

display jspuse.jsp.

end if

and

button2.click

jsptest.jsp

.

I have write by all the methods in javabeans, what I want is to use that method value on jsp.
and also want to send some value from jsp page to the class, to fetching data from database, using as parameter for the query(testbox)

Please can any one suggest me what way i should go.

Thank you in advance

Recommended Answers

All 10 Replies

Actually u only wrote partial script in ur ques. My mean is,u try with Javascript with OnClick or OnChange, or If u have DreamWeaver thn u can use Jump Menu, this is nt basically radio btns, but it is menu, whr u selct option n redirect according to tat page.

Thank you for your reply.
Now,I am creating a simple web application in which I am calling a javascript funtion

If I write the javascript function in the jsp page like this it work fine

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>

<font color="blue">Please Enter User Name and Password </font><br><br>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Implementing css and javascript</title>

<link rel="stylesheet" type="text/css" href="style.css">

<script type="text/JavaScript" >
    function validate(theForm){
    if(theForm.user.value.length==0){
        alert("UserId can't be blank");
        theForm.user.focus();
        return false;
    }else if(theForm.pass.value.length==0){
        alert("Password can't be blank");
        theForm.pass.focus();
        return false;
    }else if(theForm.pass.value.length<6){
        alert("Password length can't be less than 6 char");
        theForm.pass.focus();
        return false;
    }
}
</script>

   </head>
<body>
    <form enctype="multipart/form-data" onSubmit="return validate(this)" method="post" action=Welcome.html>
        <%--action="Welcome.html>--%>
    <table border = "0">
        <tr align="left" valign="top">
            <td>User Name:</td>
            <td><input type="text" name ="user" class="inputbox"/></td>
        </tr>
        <tr align="left" valign="top">
            <td>Password:</td>
            <td><input type="password" name ="pass" class="inputbox"/></td>
        </tr>
        <tr align="left" valign="top">
            <td></td>
            <td><input type="submit" name="submit"
                        value="submit" class="submitButton"/>

</td>
        </tr>
    </table>
</form>

</body>
</html>

But I made seperate file named newjs.js in the project and try to call it in the jsp it didnt work
validate.js

function validate(theForm){
    if(theForm.user.value.length==0){
        alert("UserId can't be blank");
        theForm.user.focus();
        return false;
    }else if(theForm.pass.value.length==0){
        alert("Password can't be blank");
        theForm.pass.focus();
        return false;
    }else if(theForm.pass.value.length<6){
        alert("Password length can't be less than 6 char");
        theForm.pass.focus();
        return false;
    }
}

index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>

<font color="blue">Please Enter User Name and Password </font><br><br>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Implementing css and javascript</title>

<link rel="stylesheet" type="text/css" href="style.css">

<<script language="JavaScript" type="text/JavaScript" src="../script/validate.js"></script>

   </head>
<body>
    <form enctype="multipart/form-data" onSubmit="returnvalidate(this)" method="post" action=Welcome.html>
        <%--action="Welcome.html>--%>
    <table border = "0">
        <tr align="left" valign="top">
            <td>User Name:</td>
            <td><input type="text" name ="user" class="inputbox"/></td>
        </tr>
        <tr align="left" valign="top">
            <td>Password:</td>
            <td><input type="password" name ="pass" class="inputbox"/></td>
        </tr>
        <tr align="left" valign="top">
            <td></td>
            <td><input type="submit" name="submit"
                        value="submit" class="submitButton"/>

</td>
        </tr>
    </table>
</form>

</body>
</html>

Can you please tell me how to intregate the js file in jsp

you have error here

<<script language="JavaScript" type="text/JavaScript" src="../script/validate.js"></script>

actually it is <script......

Thank you for your help.
It has been solved now

k welcome. wats u doing? student or programmer?

k welcome. wats u doing? student or programmer?

I am a student.
I have one more question, I have created a calender using javascript, and displaying that value in the testbox.
Then how can I send back this value of the textbox as an argument to the query in my class.

Thank you

hey thanks, ths is very useful link.

thank you for your help.
now it has been solved

thank you for your help.
now it has been solved

If you don't mind, mark it solved :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.