We help IT Professionals succeed at work.
Get Started

dynamic address form creation with keyup dropdown value update

loren_h asked
Last Modified: 2012-05-10

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'];

Open in new window

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>

<!-- 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="" />	

Open in new window

 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 4 and design_2 to 6.

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.

It is a lot of dynamics. The number of designs is variable, the number of shipping addresses is variable, the value of the dropboxes is dynamic, and the number of dropboxes themselves are variable.

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

Watch Question
Most Valuable Expert 2011
Author of the Year 2014
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE