I've seen the code you have for a form, however that was only for a row.
I have this simple form, and inside of that form I have a table with multiple rows and columns. The user enters and selects information they need to. Once done if they need another table, they can click on add and it will add another table inside of that form. If they click on delete it would remove the last table inserted.
How can I use your JS code to implement this? Any help is greatly appreciated.
I solve the adding portion but when click add for the first time, it throws the original table off alignment. Everything table you insert after that is align correctly beneath the first one added.
Can I turn the <tr id="headrow"> to <tr class="headrow"> Because I need this row to align correctly? Thanks by the way, and do you have any pointers on how to go about deleting the row just inserted.
Hi,
Has anyone got a function to remove a added row? The examples above are perfect for me just i dont fully understand how to add a bit to remove a row thats been added.
I need some help to add a function to remove a row thats been added. say if a user adds a row but then would like to remove it before the form is submitted. So there would be a link on the side of every row added. im assuming this is possible but wouldnt know, very new to playing with javascript
i'm in need of help with adding some rows to a table, i saw the script from Kor and is its very interesting but i'm not able to integrate with my table. Here is the table i have:
need help in accessing data from dynamically generated table
Hai KOR & everyone
Iam a newbie to javascript. I am developing an application which involves computation based on the user input .
The design is like this : I have a html page with javascript in which tables are dynamically generated(using your clone code), whenever user wants to add another table and give input into it . I am attaching the code here .After submiting, the values are passed to a php page where computation is done based on the input values.
The problem realy starts here like how to access data individualy from javascript which are POSTED to a php page .Please I need your help .
The html page is
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
var clone;
function cloneRow(){
var rows=document.getElementById('mytab').getElementsByTagName('tr');
var index=rows.length;
clone=rows[index-1].cloneNode(true);
var inputs=clone.getElementsByTagName('input'), inp, i=0 ;
while(inp=inputs[i++]){
inp.name=inp.name.replace(/\d/g,'')+(index+1);
}
}
function addRow(){
var tbo=document.getElementById('mytab').getElementsByTagName('tbody')[0];
tbo.appendChild(clone);
cloneRow();
}
onload=cloneRow;
</script>
</head>
<body>
<form action="m_approach2.php" method="post">
<table id="mytab">
<tr>
<td><div align="center">sigma2</div></td>
<td><div align="center">sigma4</div></td>
<td><div align="center">sigma5</div></td>
<td><div align="center">sigma7</div></td>
<td><div align="center">sigma9</div></td>
<td><div align="center">sigma10</div></td>
</tr>
<tr>
<td>
<input name="input2[]" type="text" size="5" />//is this correct? is input2[0] = value of what user entered in the first column of the second row?
</td>
<td>
<input name="input4[]" type="text" size="5" />
</td>
<td>
<input name="input5[]" type="text" size="5" />
</td>
<td>
<input name="input7[]" type="text" size="5" />
</td>
<td>
<input name="input9[]" type="text" size="5" />
</td>
<td>
<input name="input10[]" type="text" size="5" />
</td>
</table>
<br>
<input type="button" value="Add a new row" onclick="addRow()">
<input name="" type="submit" value="Submit" />
</form>
</body>
</html>
My php page is smthin like this
m_approach2.php is
Code:
<?php
set_time_limit(0);
$in=$_POST["input0"];//how to get all the inputed value in the variable?
$in0=$_POST["input"];
$in4=$_POST["input4"];
$in5=$_POST["input5"];
$in6=1-$in5;
$in7=$_POST["input7"];
$in3=1-$in4-$in7;
$in9=$_POST["input9"];
$in8=1-$in9;
$in10=$_POST["input10"];
$in11=1-$in10;
?>
Last edited by Kor; 03-10-2010 at 03:31 AM.
Reason: wrap the code [code][/code]
Ok, I have an interesting twist to the code for you Kor. I need to be able to have 3 separate add row buttons on the same page that each would be pulling a different set of variables. How would I change your code to do that? I don't really know javascript, but they want me to change a paper to be online with some changes. Any ideas?
Bookmarks