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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:05:24+00:00 2026-06-12T21:05:24+00:00

i want to add the disabled attribute on the form:hidden tag dynamically when i

  • 0

i want to add the disabled attribute on the form:hidden tag dynamically when i go over a list of objects in my model. the code i have (that doesn’t work) goes a little something like this:

<c:forEach items="${myModel.myList}" var="obj">
        <div id="${obj.id}" onclick="selectObject(this);"><span>${obj.name}</span></div>
        <form:hidden path="myModel.selectedObj" />
</c:forEach>

i want the hidden input of obj in the list that his id is equal to the selectedObj to not be disabled, and every other hidden input i want to be disabled. This is what i tried:

<form:hidden path="myModel.selectedObj" <c:out value="${obj.id != myModel.selectedObj.id ? "disabled=\"disabled\"" : ""}"></c:out> />

as i said, this didn’t work out. any thoughts?

  • 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-12T21:05:27+00:00Added an answer on June 12, 2026 at 9:05 pm

    Try with this piece of code:

    <c:forEach items="${myModel.myList}" var="obj">
        <div id="${obj.id}" onclick="selectObject(this);"><span>${obj.name}</span></div>
        <c:if test="${obj.id eq myModel.selectedObj.id}">
            <form:hidden path="myModel.selectedObj" />
        </c:if>
        <c:if test="${obj.id ne myModel.selectedObj.id}">
             <form:hidden path="myModel.selectedObj" disabled="disabled" />
        </c:if>
    </c:forEach>
    

    Or you can use a <c:choose /> , with <c:when /> and <c:otherwise /> tags:

    <c:forEach items="${myModel.myList}" var="obj">
        <div id="${obj.id}" onclick="selectObject(this);"><span>${obj.name}</span></div>
        <c:choose>
            <c:when test="${obj.id eq myModel.selectedObj.id}">
                <form:hidden path="myModel.selectedObj" />
            </c:when>
            <c:otherwise>
                <form:hidden path="myModel.selectedObj" disabled="disabled" />
            </otherwise>
        </c:choose>
    </c:foreach>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of string values that I want add to a hashtable
I have a select form field that I want to mark as readonly, as
I have this in order to replace attribute disabled with readonly and I want
I have C++ code. That code contains Windows mobile GPS enable/disable functionality. I want
I have a model that needs to have an attribute added to it to
I have a website built with ASP.NET (3.5) and want add some level of
I have problem, when I want add Node to my GUI from other Thread.
I have numbers in javascript from 01(int) to 09(int) and I want add 1(int)
I have a JqGrid with the form editing option. When I click on add
I want to add and remove class disabled on button click. I tried to

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.