Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7854695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:09:00+00:00 2026-06-02T20:09:00+00:00

I understand this question may sound very basic but I have been trying to

  • 0

I understand this question may sound very basic but I have been trying to solve it and I still haven’t been able to do it. I will really appreciate any help.

I have two radio buttons in my jsp page. When either one is selected, it calls a Javascript function. What eventually happens is if you select radio button 1, it displays data from table 1, if radio button 2 is selected, then data from table 2 is displayed.

As a result, my page gets refreshed and the radio buttons are not selected anymore. I would like to show the user which radio button was selected.

function viewUploadedData(){
    document.location.href = "ForecastInquiryFilter.do?exportVar=viewUploadedData";

function viewTopsData(radio){
    document.location.href = "ForecastInquiryFilter.do?exportVar=viewTopsData";
}
<input type="radio" name="dataTypeToView" id="topsData" onclick="viewTopsData();"/>
<label for="topsData">TOPS Data</label><br/>
<input type="radio" name="dataTypeToView" id="uploadedData" onclick="viewUploadedData();"/>
<label for="uploadedData">Uploaded Data </label>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:09:03+00:00Added an answer on June 2, 2026 at 8:09 pm

    If you generate the html for a radio button using the “checked” attribute, it will be checked. For example, the following html will generate a radio button that is checked:

    <input type=radio name=myradio value=1 checked>
    

    So, having said that, you need to modify your jsp to conditionally generate the “checked” attribute for the appropriate radio button. Presumably your jsp knows which radio button was checked, so hopefully this should be easy to code.

    So, you jsp code might look something like this:

    <%
    String whichRadio = request.getParameter("myradio");
    String r1checked = "";
    if (whichRadio.equals("1")) r1checked = " checked";
    String r2checked = "";
    if (whichRadio.equals("2")) r2checked = " checked";
    %>
    <input type=radio name=myradio value="1"<%= r1Checked %>>
    <input type=radio name=myradio value="2"<%= r2Checked %>>
    

    The above code will generate the checked attribute for whichever radio was checked when your jsp was called. If no radio was checked, then no checked attribute will be generated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question may sound silly.. but my intention is to understand advantages of Java
This may sound as a simple question for many, I am trying to understand
I understand this may sound like an odd question.. I have a repo on
I know this question may sound silly, but I am learning (at least trying)
So I understand this may come across as a open question, but I need
I know that my this question may sound pathetic to you but as a
I fully understand this question has been asked a lot , but I'm asking
This may sound silly but I didn't want to hijack a question. I recently
This question may be redundant, but i could not totally understand how to do
I understand that this question may seem somewhat ungrounded, but if someone knows anything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.