0

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

3
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by Stefano Mtangoo
0

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.

0

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

Edited by Reverend Jim: Fixed formatting

0

you have error here

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

actually it is <script......

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.