473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making a table row editable?

Hi All,

I have a web page that presents records in a table, with one row per
record.

I'd like to put an edit button next to each record, such that if a user
clicks on the edit button next to a particular record, that record
becomes an editable form.

I'm assuming this can be achieved via JavaScript, and I'm wondering if
anyone can point me at any online resources that might step me through
achieving this, as my Google-Fu is turning very high noise-to-signal.

Many thanks in advance,

pt

Nov 10 '06 #1
1 4918
planetthoughtfu l wrote:
Hi All,

I have a web page that presents records in a table, with one row per
record.

I'd like to put an edit button next to each record, such that if a user
clicks on the edit button next to a particular record, that record
becomes an editable form.
Is your "record" the contents of a cell, or the entire row?

I'm assuming this can be achieved via JavaScript, and I'm wondering if
anyone can point me at any online resources that might step me through
achieving this, as my Google-Fu is turning very high noise-to-signal.
The simplest implementation would be for a click on a cell to pop-up a
prompt with the content of the cell as its value. The user modifies
the value and the result is put back into the cell.

You could extend that significantly to putting the content of the row
into a pop-up table, use the table header to label fields, fill field
content from the row, make them editable based on a class attribute in
the original table, then drop the new values back into the form when
the user is finished (and allow a cancel too of course).

You want to investigate:

- the onclick event to make things happen
- creating elements so you can do the pop-up thing
- referencing elements so you can get the content from the table and
write it back when you're finished
- deleting elements so you can destroy the pop-up when you're
finished.

You will also want to checkout methods for sending the data back to the
sever. You might have a hidden form that you submit with changes, or
the entire table could be a form and you send back the whole lot.

This really is a bit of "how long is a piece of string" question.

Here's something really basic to start you off, the text inputs should
be type="hidden", I've left them as text so you can see what's
happening.

<script type="text/javascript">
function editEl(el){
var elText = el.innerHTML;
var dbField = el.className;
elText = prompt('Please enter a new value:', elText);
el.innerHTML = elText;
document.forms['personDetails'].elements[dbField].value = elText;
}

</script>

<table>
<tr><th>name</th><th>Age</th>
<tr>
<td class="personNa me" onclick="editEl (this);">Fred
<td class="personAg e" onclick="editEl (this);">47
</table>
<form action="" name="personDet ails" id="personDetai ls"><div>
<input type="text" name="personNam e"><br>
<input type="text" name="personAge "><br>
<input type="submit" value="Transmit changes..."></div>
</form>
HTH :-)
--
Fred

Nov 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3892
by: black tractor | last post by:
HI there.. l was just wondering, if l place a "table" in the "editable region" of my template, will the text, graphics placed inside the this "table" MOVE BY ITSELF?? l mean, recently l had a "table" insert in my "editable region", have it placed in the "center" of the page.. while it display correctly on my browser, with setting at 1024x768 (IE6),
4
1799
by: Stephan Bour | last post by:
Hi, I have a datagrid databound to a SQL query. I'd like to allow editing of some columns but not all. Is there a way to turn off the conversion of the datagrid cells to textboxes for some columns when the Edit button is pressed? Thank you, Stephan.
8
2411
by: pmud | last post by:
Hi, I have 2 questions: 1. I have an editable data grid with 21 columns. I need to edit only 2 cloumns in this data grid. But when the grid is displayed in Edit mode, all the columns show long text boxes whichmakes the user to SCROLL a lot. I need only these 2 cloumns to be displayed in Edit mode. Is that possible & how? 2. Also, even when the data grid is not displayed in the edit mode, it
4
5356
by: biswaranjan.rath | last post by:
Hi, I've few checkboxes in different rows. After selecting appropriate values, the user should click a button. I wanted to convert those checkbox values to non-editable(or non-editable textboxes), so that user cannot change the value again after the needed functionality(this is in java script) completes. So my problem is that how should i manipulate the page through java script to set the field noneditable. Please suggest.
1
1455
by: pdesh3 | last post by:
Hi, I am not getting any idea how to implement this: I have a form for which I need to create a top banner kind of the thing on top section of the Form. It should contain the feilds as DATE, PHYSICIAN NAME, LOCATION. DATE field should display intially system date, when highlighted it should be editable and it should allow to change date. PHYSICIAN NAME This field should display any doctor's name and when highlighted it...
2
1730
by: harini | last post by:
i hv a datagrid to which i hv bound a table...i hv the table columns to be editable...i.e read only = false....now i hv a problem...in the table there seems to be a row at the end having no values automatically added...and it creates prob for me...i dont want that last null row to be present in the table...so how do i mk sure tat this last empty, null row dosent get attached to my table bound to the datagrid? p.s. if i mk my datagrid as read...
7
3758
oll3i
by: oll3i | last post by:
i want to change the values in two columns one colum is a combobox and the secons column is editable too i want to get the value of that second column and the value of combobox and sent that to another application i have setValueAt(Object value,int row, int col) but it works only for combobox when i enter some data in the second editable column the value i entered disappears rows are a list data = new...
1
1278
by: ramyasarangapani | last post by:
Hi, i have a issue in html.in a table,initially all the controls should be disabled.on click of edit link in each row,the respective row controls should be editable. i have not used forms.pls help asap
0
9715
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10603
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10353
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3836
muto222
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.