sjns Posted October 30, 2010 Share Posted October 30, 2010 Hi, If someone here is willing to help me I would really appreciate how to limit the addition of columns in the following html code, let say only up to 5 only? Code: <script type="text/javascript"><!-- function addFriend() { var tbl = document.getElementById('my_friends'); var iteration = tbl.tBodies[0].rows.length; newRow = tbl.tBodies[0].insertRow(-1); var newCell = newRow.insertCell(0); newCell.innerHTML = '<?php echo $entry_friend; ?>'; var newCell1 = newRow.insertCell(1); var el = document.createElement('input'); el.type = 'text'; el.name = 'friends[]'; el.size = 30; el.maxlength = 45; newCell1.appendChild(el); // if (newCell > 2) tbl.addCell(newCell + 1); } function removeFriend() { var tbl = document.getElementById('my_friends'); var lastRow = tbl.rows.length; if (lastRow > 2) tbl.deleteRow(lastRow - 1); } //--></script> Thanks in advance Link to comment https://forums.phpfreaks.com/topic/217303-how-to-limit-the-additions-field/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.