Welcome to WebmasterWorld Guest from 3.81.28.94

Forum Moderators: open

Message Too Old, No Replies

Looking for a script

to automatic make a new line in formpost

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

Junior Member

10+ Year Member

joined:Apr 4, 2003
posts:59
votes: 0


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.

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

Senior Member from US 

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

joined:Sept 4, 2001
posts: 2294
votes: 95


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

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

Junior Member

10+ Year Member

joined:Apr 4, 2003
posts:59
votes: 0


that could work, yes.
10:52 pm on July 20, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2004
posts:2047
votes: 0


<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>
12:03 am on July 21, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 4, 2003
posts:59
votes: 0


Perfect! ;)

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

What will it be on the second and third?

code2
code3?

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2004
posts:2047
votes: 0


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.