dcsimg
www.webdeveloper.com
Results 1 to 1 of 1

Thread: dynamic form creator creates element with dynamic content

  1. #1
    Join Date
    Nov 2010
    Posts
    19

    dynamic form creator creates element with dynamic content

    Hello!

    I am trying to create a dynamic shipping form. It is very complicated, but I hope that when complete, it will be totally fool-proof. Basically, what I have set up so far is an order entry page in which a user can specify details for ordering posters.

    He can select the total quantity of posters he wants, then select the total number of different designs he wants. Say 10 total posters with a quantity of 4 for "design_1" and a quantity of 6 for "design_2".

    php is storing all this information in a session, along with some other height X width information:

    //retrieving dynamic order info
    for ($i = 1; $i <= (int)$_SESSION['number_of_individual_designs']; $i++) {
    $_SESSION['design_'.$i.'_name'] = $_REQUEST['design_'.$i.'_name'];
    $_SESSION['design_'.$i.'_qty'] = $_REQUEST['design_'.$i.'_qty'];
    $_SESSION['design_'.$i.'_size_w_1'] = $_REQUEST['design_'.$i.'_size_w_1'];
    $_SESSION['design_'.$i.'_size_w_2'] = $_REQUEST['design_'.$i.'_size_w_2'];
    $_SESSION['design_'.$i.'_size_h_1'] = $_REQUEST['design_'.$i.'_size_h_1'];
    $_SESSION['design_'.$i.'_size_h_2'] = $_REQUEST['design_'.$i.'_size_h_2'];
    $_SESSION['design_'.$i.'_num_of_extension'] = $_REQUEST['design_'.$i.'_num_of_extension'];


    I want that a customer can ship to as many different addresses as total amount of posters ordered ($qty_sum). And I want the user to be constantly informed about how many of a particular design he has remaining (without a shipping address assigned). Like this, a user will be at first confronted with a dropdown with numbers ranging between 1 and $qty_sum.

    <?

    $qty_sum=0; //holds the total qty

    for ($i=1; $i<=$_SESSION['number_of_individual_designs']; ++$i){
    ?>
    Design <?= $i ?> <br />
    Quantity <?= $_SESSION['design_'.$i.'qty']?>

    <? $qty_sum += $_SESSION['design_'.$i.'qty'];
    }


    ?>

    num of unique shipping address
    <!-- self post to self so you can get the number of address the user selected from the drop down -->
    <form method="post" action="shipping_address.php">
    <select id="num_shipping_addr" name="num_shipping_addr" onchange="submit();">
    <option value="">Select...</option>
    <?
    for ($a=1; $a<=$qty_sum; ++$a){
    ?>
    <option value="<?=$a?>"><?=$a?></option>
    <?
    }
    ?>
    </select>
    </form>


    <!-- based on the number the user selected from the dropdown box above, create the appropriate number of address fields -->
    <form method="post" action="shipping_address_process.php">
    <?
    $num_shipping_addr = $_REQUEST['num_shipping_addr'];


    for ($c = 1; $c <= $num_shipping_addr; ++$c) {
    ?>
    <h1>address <?=$c?></h1>
    address 1 <input type="text" name="address_<?=$c?>_addr_1" id="" />
    address 2 <input type="text" name="address_<?=$c?>_addr_2" id="" />


    <?
    }
    ?>
    </form>



    If he chooses 2, then two address forms will appear. At the bottom of each address form, will be a dynamic number of dropdowns. The number will be equal to the number of designs chosen. In this case, 2 designs; the user will see two lines:
    "how many of design_1 will be shipped to this address" + dropdown
    "how many of design_2 will be shipped to this address" + dropdown

    With each dropdown maxing out at the total quantity of each design. In this example, design_1's dropdown would go to 6 and design_2 to 4.

    Each time a user selects a number to be shipped in one address, the other dropdowns should update to have their maximum values reflect the number of posters which have not yet been assigned a shipping address. Also a dynamic text indicator like, "up to 3" showing that the number of posters remaining (like in the sketch "up to 15") would be very user-friendly.

    I am quite stumped about this nested dynamism. But I am convinced this can be a very cool, very idiot-proof from. Necessary for the massive amounts of information which a user must keep track of in it.

    Thank you in advance to anyone who can help me! I am self-taught, and quite at the edge of my abilities.

    I understand that this is a complex application and a lot of work. I definitely would appreciate anyone who can point me in the right direction as far as making changes to a variable iteration of an object, when it is unknown how many iterations there will be.


    Thanks so much,
    Thomas
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles