Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic table and linking 1

Status
Not open for further replies.

Bob500

Technical User
Aug 8, 2003
65
0
0
EU
Hi,

Basically I want to have a webpage with a single table that has 4 columns

1st- Date
2nd- file 1
3rd- file 2
4th- file 3

The files are word doc's that I am opening with window.open()

what I need is for the user to be able to dynamically add rows to the bottom of the table and then dynamically select the link to the file 1,2, and 3 for that date (on the row. These additions must then be saved.

Does anyone have any pointers or tutorials on how I would do this just using Javascript and html?

Many thanks :)
 
To the best of my knowledge, dynamically adding rows only works in MSIE.

To achieve the same in Mozilla you may have to destroy the old table and paste a new one with different number of rows...

----------
I'm willing to trade custom scripts for... [see profile]
 
<script>
rowCount = 1

function addRow(){
rowCount ++
theTable = document.getElementById(&quot;mainTable&quot;)
newRow = theTable.firstChild.firstChild.cloneNode(true)
newRow.childNodes[0].firstChild.name = &quot;date_&quot; + rowCount
newRow.childNodes[1].firstChild.name = &quot;file1_&quot; + rowCount
newRow.childNodes[2].firstChild.name = &quot;file2_&quot; + rowCount
newRow.childNodes[3].firstChild.name = &quot;file3_&quot; + rowCount
theTable.firstChild.appendChild(newRow)
}
</script>



<table id=&quot;mainTable&quot; border=1>
<tr>
<td><input name=&quot;date_1&quot; onblur=&quot;alert(this.name)&quot;></td>
<td><input type=file name=&quot;file1_1&quot;></td>
<td><input type=file name=&quot;file2_1&quot;></td>
<td><input type=file name=&quot;file3_1&quot;></td>
</tr>
</table><br>
<input type=button onClick=&quot;addRow()&quot; value=&quot;Add Record&quot;>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

 
Thanks for the replies,

Mwolf00, that works awesomely, except that it doesn't seem to save the rows or file that I add. Each time I open the page it is just a single blank row. How can I make it save any rows and files that I enter?

Many Thanks
 
Oh yeah, and how do I make the selected files selectable <a href= etc..> and not just a string?

Thx
 
Bob,

To save the files, you need to submit the form (make sure to set the enctype).

<form enctype=&quot;multipart/form-data&quot; action=&quot;formHandler.asp&quot;>

handling uploaded forms needs to be done server-side with asp/php/coldfusion or some other server-side code.

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top