wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes disabling and enabling input fields in a table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "disabling and enabling input fields in a table" Watch "disabling and enabling input fields in a table" New topic
Author

disabling and enabling input fields in a table

Daniel Conner
Ranch Hand

Joined: Jan 25, 2007
Posts: 47
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

Joined: Jan 10, 2002
Posts: 60797
    
  65

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 .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60797
    
  65

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.
 
jQuery in Action, 2nd edition
 
subject: disabling and enabling input fields in a table
 
Similar Threads
Issue with displaying data back on the page
How to pass multiple parameters. Displaytag row value not changing on dynamic link
struts2 and displaytag confiuration problem
maintin checkbox stauts during paginatin(dispalytag)
Problem using jstl and displaytags