Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enable/Disable a text box based on checkbox

 
Nagendra Shastry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi All,

I have a table of data. Few columns in each row has to be read only when loaded and when the check box in corresponding row is checked,these fields has to be enabled for editing.

My code for column is <display:column property="panelSerialNumber" style="text-align:right" titleKey="rmalcd.label.serial" sortable="false"></display:column>

Can someone help me in doing this? I can't use jquery(It is restriction from manager)

Regards,
Shyam
 
Akhilesh Trivedi
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it JQuery or Javascript that is restricted by manager?
 
Nagendra Shastry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

He told me not to use jquery. We can use javascript. Here we have a table of data. Once we check the checkbox that row has to be enabled for editing. we should be able to edit multiple rows before clicking on Update All button to update multiple rows.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, this isn;t a JSP question so it's been moved to the HTML forum.

Secondly, your manager is ill-informed. Most people use jQuery to make their in-browser script easier and more robust.

Make the text inputs initially disabled. Establish a change handler on the table. When a checkbox changes to checked, find the text inputs in the same row and remove the disabled attribute.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am being nice today while updating my laptop.

HTML



JavaScript



Running Example

http://jsfiddle.net/HG73V/
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And without testing, I think the jQuery code is simply:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With jQuery (roughly off the top of my head -- may need debugging):


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dueling posts: Eric snuck in in front of me!

In any case, it's clear from both examples that it's a lot less code to do it with jQuery (and multiple ways to do it).

What possible reason could there be for "Don't use a library that will make you more productive and produce more robust cross-browser code"?
 
Nagendra Shastry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks a lot Bear and Eric.. Resolved the issue with your support...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic