0
<html>   
    <head>   
        <script>   
            function goSubmit()   
            {   
                document.frm.submit();   
            }   
        </script>   
    </head>   
    <body>   
        <form action ="view1.jsp" method="post" name="frm">   
  
            <table>   
                <tr>   
                    <td>   
                        <input type="radio" name="rg" value="faculty"   onClick="goSubmit()"/>   
                    </td>   
  
                    <td>   
                        <input type="radio" name="rg" value="date"  onClick="goSubmit()"/>   
                    </td>   
  
                    <td>   
                        <input type="radio" name="rg" value="content"  onClick="goSubmit()">   
                    </td>   
                </tr>   
            </table>   
        </form>   
    </body>   
</html>  
<html>
    <head>
        <script>
            function goSubmit()
            {
                document.frm.submit();
            }
        </script>
    </head>
    <body>
        <form action ="view1.jsp" method="post" name="frm">

            <table>
                <tr>
                    <td>
                        <input type="radio" name="rg" value="faculty"   onClick="goSubmit()"/>
                    </td>

                    <td>
                        <input type="radio" name="rg" value="date"  onClick="goSubmit()"/>
                    </td>

                    <td>
                        <input type="radio" name="rg" value="content"  onClick="goSubmit()">
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

this is my code i lost the focus on which radio button is selected after submiting the form

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by sasi_88
0

What do you mean lost focus. All we see here is the same code posted twice. Do you submit at the same page? If yes then what happens is that the page reloads.
You need to take the value of the radio button from the request and set the attribute "checked" to the selected radio button.
Take the value and use java scriplets (if statements) to decide which button needs to have the "checked"

0

sorry i paste the code twice.

<html>
    <head>
        
    </head>
</html>
<body>
    <form action="sample.jsp" method="get" name="frmTest">
        <table>
            <tr>
                <td>
                    <input type="radio" name="rg" value="faculty" checked="false"/>
                </td>
                <td>
                    <input type="radio" name="rg" value="date" checked="false"/>
                </td>
                <td>
                    <input type="radio" name="rg" value="content" checked="false">
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

consider the above code it has all the three buttons are checked false
but at run the program automatically the last button is selected, how to this happened?

This topic has been dead for over six months. 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.