473,473 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to make a non editable textfields editable at a button click?

2 New Member
I have some text fields which are non editable .I want to make them editable at a button(Edit) click.Below is the code .How to do that??

Expand|Select|Wrap|Line Numbers
  1.  <FORM action="notworking.jsp" name="abc">  
  2.  
  3.             <label>First Name:
  4.  
  5.             </label>
  6.                       <positiontextbox>
  7.             <input type="text" name="fname" value="<%=rs.getString(1)%>"  id="fn" readonly />
  8.                  </positiontextbox>
  9.             <div class="spacer"></div>
  10.             <br>
  11.             <label>Last Name:
  12.  
  13.             </label>
  14.             <input type="text" name="lname"  value="<%=rs.getString(2)%>" id="ln"  readonly/>
  15.  
  16.             <div class="spacer"></div>
  17.             <br>
  18.             <label>Your Email:
  19.  
  20.             </label>
  21.             <input type="text" name="email" value="<%=rs.getString(3)%>"id="email" readonly/>
  22.  
  23.   <div class="spacer"></div>
  24.             <br>
  25.         <div class="spacer"></div><br>
  26.  
  27.     <INPUT type=submit value="Edit"   onclick="return validate()"><a></a>
  28.     <hr>
  29.     </hr>    
  30.              </FORM>
Apr 7 '12 #1
4 18143
Luuk
1,047 Recognized Expert Top Contributor
look here

which basically is:
1) you need javascript
2) don't use 'readonly', but use 'disabled="true"'
Apr 7 '12 #2
Amrit Pathak
2 New Member
Thanks.Can you please tell me how to make these fields(3) enable at button click?
Apr 8 '12 #3
Luuk
1,047 Recognized Expert Top Contributor
Please use the CODE-tags around some code you post here:
Expand|Select|Wrap|Line Numbers
  1. <FORM action="notworking.jsp" name="abc"> 
  2.  
  3.  
  4. <script type="text/javascript">
  5. function validate() {
  6.     x=document.getElementById("fn")
  7.     x.disabled = !x.disabled;
  8.     x=document.getElementById("ln")
  9.     x.disabled = !x.disabled;
  10.     x=document.getElementById("email")
  11.     x.disabled = !x.disabled;
  12. }
  13. </script>
  14.  
  15. <label>First Name:
  16.  
  17. </label>
  18. <positiontextbox>
  19. <input type="text" name="fname" value="<%=rs.getString(1)%>" id="fn" disabled="true" />
  20. </positiontextbox>
  21. <div class="spacer"></div>
  22. <br>
  23. <label>Last Name:
  24.  
  25. </label>
  26. <input type="text" name="lname" value="<%=rs.getString(2)%>" id="ln" disabled="true"/>
  27.  
  28. <div class="spacer"></div>
  29. <br>
  30. <label>Your Email:
  31.  
  32. </label>
  33. <input type="text" name="email" value="<%=rs.getString(3)%>"id="email" disabled="true"/>
  34.  
  35. <div class="spacer"></div>
  36. <br>
  37. <div class="spacer"></div><br>
  38.  
  39. <INPUT type=button value="Edit" onclick="return validate()"><a></a>
  40. <hr>
  41. </hr> 
  42. </FORM>
note:
1. the button type on the edit button changed
2. "readonly" was changed to "disabled='true'"
Apr 8 '12 #4
Bharat383
93 New Member
<input type="text" readonly="readonly">
Apr 16 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
5
by: Charlie J | last post by:
I have developed a website with several (30) pages that works just fine on my development machine (XP Pro SP2). When I move the site to the server (W2K3) I have 7 pages where a mouse click on a...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
7
by: Diane | last post by:
Hi- I've been struggling with this problem and none of the fixes posted seem to help out at all. Yet, it seems like such a simple problem... I have a DataGrid, and load it up with data on...
1
by: Samuel Shulman | last post by:
Any method to make a cell editable programmatically The problem is that if the user entered a value which is not valid then instead of ignoring the value and explaining the user what was wrong ...
0
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi, How can I make RequiredFieldValidator triggered on button click? in my form I have a wizard that contain a search button few textboxes with RequiredFieldValidators for each and I have set...
0
by: Valli | last post by:
Hi, I am having a master page & a content page in my project. My content page contains button click event codings.(default.aspx.vb) But the button click event is not getting fired when I click...
4
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
0
by: ADN | last post by:
Hi, I am currently extending the GridView control and would like to add a button to the GridView so that it will automatically render one button at the top of the grid. I have a click event for...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.