Jump to content

how to limit the additions field?


sjns

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.