I have a contacts table that contains a column for contact_id
. Can someone help me update a table row based on contact_id
? For example, I have the following table:
<table class="table table-condensed" id="company_contacts_table">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Phone #</th>
<th>Notes</th>
<th></th>
<th></th>
<th hidden></th>
</tr>
</thead>
<tbody>
<tr>
<td>Jake</td>
<td>Dang</td>
<td>jake123@gmail.com</td>
<td>7032669955</td>
<td>contact_notes</td>
<td><button type="update" class="btn btn-primary update_contact" href="#update_contact_modal" data-toggle="modal" id="some_contact_id">Update</button></td>
<td><button type="update" class="btn btn-danger delete_contact" id="some_contact_id">Delete</button></td>
<td hidden>some_contact_id</td>
</tr>
<tr>
<td>Harrison</td>
<td>WElls</td>
<td>Hwells@gmail.com</td>
<td>7039998888</td>
<td>contact_notes</td>
<td><button type="update" class="btn btn-primary update_contact" href="#update_contact_modal" data-toggle="modal" id="some_contact_id2">Update</button></td>
<td><button type="update" class="btn btn-danger delete_contact" id="some_contact_id2">Delete</button></td>
<td hidden>some_contact_id2</td>
</tr>
<tr>
<td>Mason</td>
<td>Hanley</td>
<td>mnahley@gmail.com</td>
<td>7032669855</td>
<td>contact_notes</td>
<td><button type="update" class="btn btn-primary update_contact" href="#update_contact_modal" data-toggle="modal" id="some_contact_id3">Update</button></td>
<td><button type="update" class="btn btn-danger delete_contact" id="some_contact_id3">Delete</button></td>
<td hidden>some_contact_id3</td>
</tr>
</tbody>
</table>
Each row contains a hidden contact_id
column. I want to update the first name, last name, email, phone #, notes based on the contact id. Sample pseudocode:
var my_contact_id = some_contact_id
var new_first_name = 'george'
var new_last_name = 'henry'
var new_email = 'tinpopo@hotmail.com'
var new_phone = 999-333-4444
- Find row that contains `some_contact_id`
- Set first name, last name, email, phone to new first name, new last name, new email, new phone
Can someone help?
Thanks in advance!!
var new_first_name = 'george'
var new_last_name = 'henry'
var new_email = 'tinpopo@hotmail.com'
var new_phone = 999-333-4444
var tr = $("#company_contacts_table td:contains("+some_contact_id+")").closest("tr").find("td");
tr[0].innerHTML = new_first_name;
tr[1].innerHTML = new_last_name;
tr[2].innerHTML = new_email;
tr[3].innerHTML = new_phone;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.