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 7735231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:26:57+00:00 2026-06-01T07:26:57+00:00

I have a jsp where some radio buttons and textboxes depend on dropdown selection.

  • 0

I have a jsp where some radio buttons and textboxes depend on dropdown selection.
Here is my jsp and javascript code.

jsp

         <s:form action="crInquiry" name="form">    
            <s:select name="filterValue" list="headerList"
    onchange="OnChange(this.form.filterValue);" />
            <s:radio name="filter" list="#{'STATUS_FILTER_START':'START','STATUS_FILTER_END':'STOP'}" 
label="Stage"></s:radio>
            <s:textfield disabled="true" value="0" name="count" theme="css_xhtml"></s:textfield>
            <s:radio name="ascOrder"  list="#{'ASC':'ASC','DESC':'DESC'}"></s:radio>
            <s:submit value="Filter" onclick="gotopage('FilteredInquiryLog')"></s:submit>
            <s:submitvalue="Details" onclick="gotopage('crInquiry')"></s:submit>
            </s:form>

javascript

<script type="text/javascript">
    function OnChange(dropdown) {
        var myindex = dropdown.selectedIndex;
        document.form.filter[0].disabled = false;
        document.form.filter[1].disabled = false;
    if (myindex == 8) {
            alert("8");
            document.form.filter[0].disabled = true;
            document.form.filter[1].disabled = true;
            document.form.count.disabled = false;
            document.form.submit.disabled = false;
        }
        else if (myindex == 9) {
            alert("9");
            document.form.filter[0].disabled = true;
            document.form.filter[1].disabled = true;
            document.form.count.disabled = true;
            document.form.submit.disabled = false;
        }

        else{
            document.form.filter[0].disabled = false;
            document.form.filter[1].disabled = false;
            document.form.count.disabled = true;
            document.form.submit.disabled = false;
            }
        }


    function gotopage(actionname)
    {   
            document.form.action=actionname+".action";
            document.form.submit();
    }
</script>

The problem is when I select an item on dropdown say element no. 8 or 9 so by javascript radio buttons should be disabled for both and textfield and radio button for 9.
When I select an item it disabled dependent radion button or textfield perfectly but when I submit, it show me the radio button enabled because I come to the same jsp.
What is the problem in my javascript?

  • 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-01T07:26:58+00:00Added an answer on June 1, 2026 at 7:26 am

    You should check your dropdown value also on page onload event.

    Something like this

    <script type="text/javascript">
    
    /**
    * This function will be called twice - once on onChage event, and once on onLoad event
    */
        function OnChange() {
        dropdown = document.getElementById('myDropDown');
            var myindex = dropdown.selectedIndex;
            document.form.filter[0].disabled = false;
            document.form.filter[1].disabled = false;
        if (myindex == 8) {
                document.form.filter[0].disabled = true;
                document.form.filter[1].disabled = true;
                document.form.count.disabled = false;
                document.form.submit.disabled = false;
            }
            else if (myindex == 9) {
                document.form.filter[0].disabled = true;
                document.form.filter[1].disabled = true;
                document.form.count.disabled = true;
                document.form.submit.disabled = false;
            }
    
            else{
                document.form.filter[0].disabled = false;
                document.form.filter[1].disabled = false;
                document.form.count.disabled = true;
                document.form.submit.disabled = false;
                }
            }
    
    
        function gotopage(actionname)
        {   
                document.form.action=actionname+".action";
                document.form.submit();
        }
    </script>
    
    <body onload="OnChange()">
    <s:form action="crInquiry" name="form">    
                <s:select name="filterValue" list="headerList" id="myDropDown"
        onchange="OnChange();" />
                <s:radio name="filter" list="#{'STATUS_FILTER_START':'START','STATUS_FILTER_END':'STOP'}" 
    label="Stage"></s:radio>
                <s:textfield disabled="true" value="0" name="count" theme="css_xhtml"></s:textfield>
                <s:radio name="ascOrder"  list="#{'ASC':'ASC','DESC':'DESC'}"></s:radio>
                <s:submit value="Filter" onclick="gotopage('FilteredInquiryLog')"></s:submit>
                <s:submitvalue="Details" onclick="gotopage('crInquiry')"></s:submit>
                </s:form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am new in JSP,i have some problem with the following code : <%@
I have custom JSP tags that generate some HTML content, along with some javascript
I have some JSP code, which writes a tree representing hierachical data. This data
I'm a c# developer but have a job that involves some jsp code. I've
I have a JSP program that displays a form where the user enters some
I have a JSP (AddDocument.jsp) with the following form: <form action= ${pageContext.request.contextPath}/project?to=submitAdd&idProject=${param.idProject} method=post name=form>
I have some old jsp code that uses the struts tags inside attributes, like
I have a JSP page that needs to accept some info into a form,
I have a Tomcat 6.0.24 server running. I'm using to run some JSP pages.
Its been a while since I had to do some Java/JSP... I have a

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.