Forum Moderators: open

Message Too Old, No Replies

Looking for a script

to automatic make a new line in formpost

         

finoo

8:10 pm on Jul 20, 2007 (gmt 0)

10+ Year Member



Hi

I've been googling for some time for this, but no luck so far. Guess i don't use the right words.

This is what im looking for, i hope someone here migth point me in the right direction.

Im making a invoice script, and are struggelig with the java/ajax(not my strongest side)
An invoice often contain more then one line.

Lets say my invoice should have theese lines :

# ¦ Description ¦ Price ¦
1 ¦ Newspaper ¦ 1$ ¦
1 ¦ Eggs ¦ 2 $ ¦
2 ¦ Milk ¦ 1 $ ¦
1 ¦ Newspaper ¦ 1$ ¦
1 ¦ Eggs ¦ 2 $ ¦
2 ¦ Milk ¦ 1 $ ¦

I want to have 3 lines to show by default, and if i need more lines to write in i hit a javabutton, and a new line apperers...

Hope someone can kick me in the right direction.

Marshall

8:16 pm on Jul 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are you talking about a script where when a person selects an option from a dropdown menu another option appears? If so, this has been discussed here before, but I cannot remember the thread. Try searching WebmasterWorld. If you have no success, I have a script that does this.

Marshall

finoo

10:05 pm on Jul 20, 2007 (gmt 0)

10+ Year Member



that could work, yes.

Bernard Marx

10:52 pm on Jul 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<html><head><title>TEST</title> 
<script>
function addRow(id){
var table = document.getElementById(id);
var tbody = table.getElementsByTagName('tbody')[0];
var row = tbody.rows[tbody.rows.length-1].cloneNode(true);
/* Note that cloneNode will copy attributes.
* This is probably useful wrt names, need to clear values: */
var inputs = row.getElementsByTagName('input');
for(var k=-1, input; input=inputs[++k];)
input.value = "";
tbody.appendChild(row);
}
</script>
</head>
<body>
<table id="invoiceTable">
<thead>
<tr>
<th>Code</th>
<th>Description</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td><input name="code" type="text" value=""></td>
<td><input name="desc" type="text" value=""></td>
<td><input name="pric" type="text" value=""></td>
</tr>
</tbody>
<tfoot>
<td colspan="3">
<button onclick="addRow('invoiceTable')">add row</button>
</td>
<tfoot>
</table>
</body>
</html>

finoo

12:03 am on Jul 21, 2007 (gmt 0)

10+ Year Member



Perfect! ;)

Another question on the first textarea the name is name="code"

What will it be on the second and third?

code2
code3?

Bernard Marx

8:13 am on Jul 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No. The name is always the same. There sholdn't be any problem indealing with this, either client-side or server-side, since order can be used.