Jump to content

Need help coding


oracle259

Recommended Posts

How do I allow users to add as many additional input boxes as they need. eg i have a conference room booking solution which provides for 6 participants how do i allow users to add another input box for more than 6 participants or delete extra input boxes for less than 6 participants but 1 input box must remain. Any ideas?
Link to comment
https://forums.phpfreaks.com/topic/25345-need-help-coding/
Share on other sites

i havent started coding this section bcause i knew it was going to give me troble so i decided to seek help first. But simply all i want to do i allow user s to click on a link that says 'add more members' when they click the link an additional input box appears and allows them to input the name of the individual. You can forget the delete part that seems overly complex
Link to comment
https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-115553
Share on other sites

try
[code]<html>
<head>
<script language="JavaScript1.3" >
<!--
function row(){
var table=window.document.getElementById("table1");
var newRow = document.createElement("tr");
var newCell=newRow.appendChild(document.createElement("td"));
var input=newCell.appendChild(document.createElement("input"));
input.type="text";
input.name="frend[]";
table.appendChild(newRow);
}
-->
</script>
</head>
<body>
<?php
if ($_POST) {
//for ($x=0;$x<5;$x++) $c["cell".$x]=$_POST['cell'.$x];
print "<pre>";
print_r($_POST);
print "</pre>";
}
?>
<form method="POST" action="">
<input type="button" value="AdRow" onclick="row()">
<input type="submit"><br />
<table id="table1" border="3px" width="20%" align="left" >
<tr>
<td width="20%" align="center">FREND</td>
</tr>
</table><br />
</form>
</body>
</html>[/code]
Link to comment
https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-115605
Share on other sites

Thanks it works. But im curious how do i amend the code to delete unwanted input boxes. For example i add the same person at boxes 3 and 8 of 21 how do i amend the code to allow users to delete each individual input box. May be i could add a link beside each input box that when click deletes that specific input box.

If you have any ideas pls tell me.

Thanks again
Link to comment
https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-116830
Share on other sites

[code]<html>
<head>
<script language="JavaScript1.3" >
<!--
var count = 0;
function row(){
count = count +1;
var table=window.document.getElementById("table1");
var newRow = document.createElement("tr");
newRow.id = 'row'+count;

var newCell=newRow.appendChild(document.createElement("td"));
for (var i=0;i<5;i++){
var input=newCell.appendChild(document.createElement("input"));
input.type="text";
input.name="frend["+count+"][]";}
var a = newCell.appendChild(document.createElement("a"));
a.href="javascript:moveRow("+count+")";
a.innerHTML ='Remove row';

table.appendChild(newRow);
}
function moveRow(i) {
var row = document.getElementById("row"+i);
row.parentNode.removeChild(row);
}
-->
</script>
</head>
<body>

<?php
if ($_POST) {
//for ($x=0;$x<5;$x++) $c["cell".$x]=$_POST['cell'.$x];
print "<pre>";
print_r($_POST);
print "</pre>";
}
?>

<form method="POST" action="">
<input type="button" value="AdRow" onclick="row()">
<input type="submit"><br />
<table id="table1" border="3px" width="80%" align="left" >
<tr>
<td width="20%" align="center">FREND</td>
</tr>
</table><br />
</form>
</body>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-116964
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.