Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

disabling and enabling input fields in a table

 
Daniel Conner
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an editable table with many different input fields.. I use a checkboxes for row selection. I have all of the fields disabled. The want the fields in a particular row to be enabled when that row is selected. Right now I have an onclick event calling a function to the enable the row when selected... The problem that I have is that only the first row is being enabled. Here is a snippet from my html:

<input type="checkbox" name="tableRowId" id="sid"
value="<c ut value='${mgmt.id}' />"
onKlick="enableRows();"/>

<display:column title="Desc." sortable="true">
<input type="text" name="description"
style="font-size:smaller"
value="<c ut value='${logmgmt.description}' />"
id="txtDescription" disabled="true" />
</display:column>

<display:column title="Weight" sortable="true">
<input type="text" name="weight"
style="font-size:smaller"
value="<c ut value='${logmgmt.weight}' />"
id="txtWeight" disabled="true" />
</display:column>

<display:column title="Cost" sortable="true">
<input type="text" name="cost"
style="font-size:smaller"
value="<c ut value='${logmgmt.cost}' />"
id="txtCost" disabled="true" />
</display:column>


Here is my enableRows function:

function enableRows() {
var description = document.getElementById("txtDescription");
var weight = document.getElementById("txtWeight");
var cost = document.getElementById("txtCost");

cost.disabled = false;
weight.disabled = false;
description.disabled = false;
}

So, how do I remedy the situation to be able to enable any row that is selected. Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and most people will just move on. Please read this for more information.

Also be sure to enable the 'disable smilies' checkbox so that your code looks less surprised

Lastly, I'm not sure of the practicality of showing code primarily composed of JSP markup in an HTML forum. Perhaps posting the resulting HTML would make more sense.

You can go back and change your post to add code tags by clicking the .
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks to me as if you are assigning the same id values to the element of each row of the table. An id value needs to be unique within a page.

You'll need to assign unique ids to each page element.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic