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

  • Home
  • SEARCH
  • 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 4621162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:39:39+00:00 2026-05-22T02:39:39+00:00

The jQuery attr() does not update its value on changing. Here is my code

  • 0

The jQuery attr() does not update its value on changing. Here is my code below:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-1.6.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    var Religion = $("#Religion"),
        SelectCaste = $("#SelectCaste"), 
        Hindu = $("#Hindu"), 
        Muslim = $("#Muslim"), 
        Christian = $("#Christian");

        Religion.change(function(){ 
        var sReligion = $(this).val();  
        SelectCaste.hide().attr('name', '');
        Hindu.hide().attr('name', '');
        Muslim.hide().attr('name', '');
        Christian.hide().attr('name', '');
        if(sReligion=="1") {
                Hindu.show();
                Hindu.attr('name','Caste');
            }
            else if(sReligion=="2") {
                Muslim.show();
                Muslim.attr('name','Caste');
            }
            else if(sReligion=="3") {
                Christian.show();
                Christian.attr('name','Caste');
            }
    });
});
</script>
</head>

<body>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
    <td>Religion</td>
    <td>
        <select class="FormInput" name="Religion" id="Religion">
            <option selected="selected" label="Select" value="">- Select Religion -</option>
            <option label="Hindu" value="1">Hindu</option>
            <option label="Muslim" value="2">Muslim</option>
            <option label="Christian" value="3">Christian</option>
        </select>
    </td>
</tr>
<tr>
    <td>Caste</td>
    <td>
        <select class="FormInput" id="SelectCaste" disabled="disabled">
            <option value="" selected="selected">- Select Caste -</option>
        </select>
        <div id="CasteList"> 
        <select class="FormInput" id="Hindu" style="display:none">
            <option value="" selected="selected">- Select Caste -</option>
            <option value="1">Ad Dharmi</option>
            <option value="2">Adi Dravida</option>
            <option value="3">Aggarwal</option>
            <option value="4">Agri</option>
            <option value="5">Ahom</option>
            <option value="6">Ambalavasi</option>
            <option value="7">Arora</option>
            <option value="8">Arunthathiyar</option>
            <option value="9">Arya Vysya</option>
            <option value="10">Others</option>
        </select>
        <select class="FormInput" id="Muslim" style="display:none">
            <option value="" selected="selected">- Select -</option>
            <option value="328">Ehle Hadith</option>
            <option value="329">Gulf Muslims</option>
            <option value="330">Memon</option>
            <option value="331">Ansari</option>
            <option value="332">Arain</option>
            <option value="333">Awan</option>
            <option value="334">Bengali</option>
            <option value="357">Others</option>
        </select>
        <select class="FormInput" id="Christian" style="display:none">
            <option value="" selected="selected">- Select -</option>
            <option value="358">Born Again</option>
            <option value="359">Bretheren</option>
            <option value="360">CMS</option>
            <option value="361">CNI</option>
            <option value="362">CSI</option>
            <option value="363">Catholic</option>
            <option value="364">Roman Catholic</option>
            <option value="365">Evangelical</option>
            <option value="376">Others</option>
        </select>
        </div>
    </td>
</tr>
</table>
</body>
</html>

On changing the ‘Religion’ selectbox, the other dropdown boxes (Hindu / Muslim / Christian) does not hold the attribute name=”Caste”.

Please assist me to fix the issue..

Thanks.

  • 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-05-22T02:39:40+00:00Added an answer on May 22, 2026 at 2:39 am

    It seems to be working: http://jsfiddle.net/qWasX/1/

    Are you sure you are having problems with your script?

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

Sidebar

Related Questions

The following codes works without jquery. I insert data but it does not update
I have some jQuery code something like this: $(document).ready(function() { $(img.off).click(function() { alert('on'); $(this).attr('class',
jQuery $.ajax() does not seem to work correctly with IE8 but it is working
I have this small jquery script that does not work if I remove the
I have some code in jquery which looks like this: $(#filterZaal).attr(disabled, disabled); $(#filterGenre).attr(disabled, disabled);
Here is my simple jQuery function to partially update a page <script type=text/javascript> $(document).ready(function
I need to change an element's ID using jQuery. Apparently these don't work: jQuery(this).prev(li).attr(id)=newid
Using jQuery, how do you bind a click event to a table cell (below,
I can disable one and one by doing this: jQuery('#ListBoxA').attr('disabled','true'); But how can I
On submit button i want to disable the button so user does not click

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.