Jump to content

Archived

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

oracle259

Need help coding

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?

Share this post


Link to post
Share on other sites
That's pretty vague. Can you maybe show some of your existing code and explain what you want your code to do? Is this on a page where users/the user needs to be logged in to edit the form?

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
also how can i modify the jscript to allow for multiple input boxes in the same row. For example say that row 1 as 3 input boxes, same a row 2 but i want a 3rd row which must also have 3 input boxes how do i go about accomplishing that.

Thanks again 4 ur  help

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.