Jump to content

Add rows to an html table with javascript...how?


dwest

Recommended Posts

Javascript novice here.
All of this would reside in a PHP form page connected to a database.  Other data would be present on the page such as customer info but I've left that out of the conversation since it is handled via PHP.

Using javascript, I need to generate new rows for an html table:

Assume a combo box, a button, and an html table as below:

add standard item (combo box)
add custom item (button)

(Each of these fields would need to be generated in a textbox so they could be edited.)
sku        name              descr                qty      price        [u]delete[/u]
b321      product1          nice product        1        $1.00        checkbox
b322      product2          nicer product      1        $2.00        checkbox
b323      product3          nicest product      1        $3.00        checkbox

The add standard item combo box would need to be populated from the database "items" table. The sku and name would need to be visible.  Upon selecting an item, its data is added to the html table above.  Again, with each field being a textbox.

The add custom item button would simply add another row to the html table with empty textboxes awaiting entry of the custom data.

The delete link (the last column) deletes any rows for which the checkbox is checked.

[b]So, my question then is how do I accomplish this???[/b]

For clarity, once all items are added to the table, the form is posted to a form handler and the rows are inserted into a database table along with the customer id, and other data collected on the form.

Thanks!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.