Jump to content

Adding a table row full of elements to the end of a table programatically

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
adaykin

adaykin

    Newbie

  • Members
  • Pip
  • 5 posts
Hello, I want for the user to be able to click on a button that lets them add a <tr> full of <td>'s and <input>'s in the <td> tags. So I have code like:


<script type="text/javascript">

function addRow()

{

// Insert a row too the table with td's and input's

}

</script>


<table>

<tr>

<td><input type="text" name="part1" /></td><td><input type="text" name="price1" /></td>

</tr>

<tr>

<td><input type="text" name="part2" /></td><td><input type="text" name="price2" /></td>

</tr>

</table>


<form>
<input type="button" onclick="addRow();" value="Add a Row" />
</form>
so after the last </tr> tag, I want to add that row, how would I do this?

#2
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Explore the Javascript DOM. Use getElement ByID(), I believe, to reference the table, and then add rows from there.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#3
adaykin

adaykin

    Newbie

  • Members
  • Pip
  • 5 posts
Yeah that is the way I would do it, but the problem is I can't create elements that have closing tags, so my table gets messed up. The elements are there, but without a closing tag, the table structure is bad, I forgot to mention that before.

#4
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Why can't you add elements with closing tags?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#5
sohel04

sohel04

    Newbie

  • Members
  • Pip
  • 3 posts
I would do it, but the problem is I can't create elements that have closing tags, so my table gets messed up. The elements are there, but without a closing tag, the table structure is bad, I forgot to mention that before.
irs tax problem poker casino

#6
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
I don't think I understand still, what's wrong with closing tags.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#7
adaykin

adaykin

    Newbie

  • Members
  • Pip
  • 5 posts
I actually solved this a while ago, the problem was that when you add those elements programatically you have to do it differently in firefox and ie, so I just had to detect what browser the client was using.

#8
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Oh, I see. Glad you got it working.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums