SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with dynamic table with multiple input tags

    After searching through the forum, I couldn't find the answer that I was looking for

    heres my problem. I have form that the user can use to submit a new job order and after the user submits an order, I will dynamically create a table to store all this information. Each row of the table will store the information for each job order. Along with the information, "Increase" and "decrease" buttons are also dynamically created in the row to allow the user to adjust the existing orders. "increase" increases the number of boxes to be shipped and vice versa for "decrease" . it looks something like this

    ----------------------------------------------------------------
    compon name | component ID | amount | "Increase" | "Decrease" |
    ----------------------------------------------------------------
    Intel celeron | In 1002 | 244 | <input> | <input> |
    ----------------------------------------------------------------
    HP printer | HP 245 |23 | <input> | <input> |
    ----------------------------------------------------------------

    Now the table is dynamically created, and once the user inputs how many they want to increase it will automatically adjust the value displayed in "amount" . I am having extreme difficulty on figuring out how to get the values in a dynamic table with multiple <input> tags. Also how can I ensure that I adjust the right job order. thanks in advance.

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're building these table "on the fly" you can then also set unique IDs to the input fields based on the row you are creating at that moment... without seeing HOW you are creating the tables its going to be tough to hit exactly what you are looking for but heres a quick "go at it"

    Also ... you dont really need two buttons, one to increase one to decrease as you can us a prompt to allow them to do whichever.... here's some code:

    Code:
    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> Prompt Change </title>
    <script type="text/javascript">
    <!--
    	function increaseAmount(myID)	{
    		document.getElementById(myID).value = prompt("Please enter an amount", "");
    		}
    //-->
    </script>
    </head>
    
    <body>
    <table>
    <tr>
    	<td>Intel celeron</td>
    	<td>In 1002</td>
    	<td>
    		<input type='text' id='In 1002' name='quantity' value='244' readonly'></td>
    	<td>
    		<input type='button' value='Change Quantity' onclick="increaseAmount('In 1002');"></td>
    </tr>
    </table>
    </body>
    </html>
    Now depending on HOW you are dynamically writing these rows you can add that ID to the textbox .... Ive used that because its a LOT easier to write to, as opposed to the html and I set the field to readonly... BTW, I would NEVER use IDS that had a space in them .... to many issues. Notice I also only used ONE button to give the prompt so they can increase or decrease at will.

    This could also be done by just using the quantity textbox and letting them change it there .......... but again Im not 100% sure exactly how you are using them..... personally thats how I would have handled this, NOT with the button / prompt thingy.

    hope this was what you were looking for .....

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i sent u a message. btw great site


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •