473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 4901
planetthoughtful 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="personName" onclick="editEl(this);">Fred
<td class="personAge" onclick="editEl(this);">47
</table>
<form action="" name="personDetails" id="personDetails"><div>
<input type="text" name="personName"><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
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...
4
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...
8
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...
4
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...
1
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...
2
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...
7
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...

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.