I would like to have a price field populate with a price, based on conditions of a series of dynamic dropdown boxes. I have the dropdown boxes populating, but I cannot figure out what the function should be to add a value to a text box rather than a dropdown box.

Here is my code:

I've clumped excalation marks beside the parts that I believe my problem lies in.

I appreaciate any help!

<?php
    require('../xjax/xajax_core/xajax.inc.php');
    $xajax = new xajax();
    //$xajax->configure('debug',true);
     
    class myXajaxResponse extends xajaxResponse {
     
      function addCreateOptions($sSelectId, $options) {
        $this->script("document.getElementById('".$sSelectId."').length=0");
        if (sizeof($options) >0) {
           foreach ($options as $option) {
             $this->script("addOption('".$sSelectId."','".$option."','".$option."');");
           }
         }
      }
        
        function addValue($sSelectId, $data) {   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        $this->script("document.getElementById('".$sSelectId."')");
               $this->script("addOption('".$sSelectId."','".$data."');");
           
         }
     
    }
     
          $type = array('postcards','brochure / letter','invitations','grahic design');

          $sizes = array(
            'postcards'=>array('--select--','4x6','5.5 x 8.5','5.5 x 11'),
            'brochure / letter'=>array('--select--','8.5 x 11 Trifold','8.5 x 11 Half-fold','5.5 x 14 Half-fold'),
            'invitations'=>array('--select--','4.25 x 5.5 100lb Matte Color','5.5 x 8.5 100lb Gloss Color','8.5 x 12.5 100lb Matt Text'),
                    'grahic design'=>array('--select--','per template design','Per Hour Graphic Design'),
          );

          $quantity = array(
            '4x6'=>array('--select--','1,000','3,000','5,000','10,000','15,000','20,000','30,000','50,000'),
            '5.5 x 8.5'=>array('--select--','1,000','3,000','5,000','10,000','15,000','20,000','30,000','50,000'),
            '5.5 x 11'=>array('--select--','1,000','3,000','5,000','10,000','15,000','20,000','30,000','50,000'),
            '8.5 x 11 Trifold'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
            '8.5 x 11 Half-fold'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
            '5.5 x 14 Half-fold'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
            '4.25 x 5.5 100lb Matte Color'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
            '5.5 x 8.5 100lb Gloss Color'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
                    '8.5 x 12.5 100lb Matt Text'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
                    'Per Template Design'=>array('----'),
                    'Per Hour Graphic Design'=>array('----'),
                    );
                    
                    

          // adds an option to the select
          function addSizes($selectId, $type) {
            global $sizes;
            $objResponse = new myXajaxResponse();
            $data = $sizes[$type];
            $objResponse->addCreateOptions($selectId, $data);
                    //return $objResponse->getXML();
                    return $objResponse;
              }
          function addQuantity($selectId, $sizes) {
            global $quantity;
            $objResponse = new myXajaxResponse();
            $data = $quantity[$sizes];
            $objResponse->addCreateOptions($selectId, $data);
            //return $objResponse->getXML();
                    return $objResponse;
          }


                function addPrice($selectId, $quantity, $sizes, $type) {!!!!!!!!!!!!!!!!!!!!!!!!!
            global $price;
            $objResponse = new myXajaxResponse();
                    if ($mode=='postcards'&&$sizes=='4x6'&&$quantity=='1,000')
                    {
                          $data = '2.00';
                    }
                    $data = '2.00';
            $objResponse->addValue($selectId, $data);
            //return $objResponse->getXML();
                    return $objResponse;
                         
    }
                
                
          $xajax->registerFunction("addSizes");
          $xajax->registerFunction("addQuantity");
                $xajax->registerFunction("addPrice");
          $xajax->processRequest();
          ?>
          <?
          if (isset($_POST['Submit'])) {
            print_r($_POST);
          }
          ?>
        <html>
          <head>
          <title>AJAX Dynamic Drop Down Tutorial</title>
          <?
          $xajax->printJavascript("../xjax/");
          ?>
    <script type="text/javascript">
      function addOption(selectId, val, txt) {
        var objOption = new Option(txt, val);
         document.getElementById(selectId).options.add(objOption);
       }
    </script>
          </head>




    <form action="" method="POST" name="form1" id="form1">



    <p>Simply fill out our short order form, agree to our terms and conditions, and then click Submit. Postcard Pros does not require payment or credit card information with your online order. Once your order is submitted, it will be reviewed and you will be contacted by one of our highly trained Customer Service Representatives for any more information and payment details.</p>
    <p>Thanks,</p>


    <table border="0" width="100%">
            <tr>
                <td colspan="2"><h1>Contact Information</h1><div class="blogHeaders" style="font-size: 0.8em;">*Required Field</div></td>
            </tr>
            
            <tr>
                <td width="216">
                    If you've received a custom quote from one of our customer representatives, please enter your quote number:
                </td>    
                <td width="244">
                    <input name="order_quote_number" size=30>
                </td>
            </tr>
            <tr>
                <td class="blogHeaders" width="216">* Name</td>
                <td width="244"><input name="order_customer_name" size=30></td>
            </tr>

            <tr>
                <td class="blogHeaders">* Company Name</td>
                <td><input name="order_customer_company" size=30></td>
            </tr>
            <tr>
                <td class="blogHeaders">* Address</td>
                <td><textarea row=3 cols=20 name="order_customer_address"></textarea></td>
            </tr>

            <tr>
                <td class="blogHeaders">* City, ST, Zip</td>
                <td><input name="order_customer_city_state_zip" size=30></td>
            </tr>
            <tr>
                <td class="blogHeaders">* Phone #</td>
                <td><input name="order_customer_phone" size='12'></td>
            </tr>

            <tr>
                <td>&nbsp;&nbsp;Fax #</td>
                <td><input name="order_customer_fax" size='11'></td>
            </tr>
            <tr>
                <td class="blogHeaders">* Email</td>
                <td><input name="order_customer_email" size='30'></td>
            </tr>
            <tr>
                <td>&nbsp;&nbsp;Web Site</td>
                <td><input name="order_customer_website" size='40'></td>
            </tr>
                    <tr>
                <td colspan="2"><br><br></td>
            </tr>
            <tr>
                <td colspan="2"><h1>Product Information</h1><div class="blogHeaders" style="font-size: 0.8em;">*Required Field</div></td>
            </tr>
            <tr>
                <td class="blogHeaders" width="216">* Product Type</td>
                <td width="244">
                    <select name='order_product_type'>
                        <option value='postcard'>Postcard</option>
                        <option value='Brouchure / Letter'>Brochure / Letter</option>
                        <option value='Invitations'>Invitations</option>
                        <option value='Graphic Design'>Graphic Design</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="blogHeaders" width="216">* Select Product Dimensions</td>
                <td width="244">
                    <select name='order_product_dimensions'>
                        <option value='postcard'>Postcard</option>
                        <option value='Brouchure / Letter'>Brochure / Letter</option>
                        <option value='Invitations'>Invitations</option>
                        <option value='Graphic Design'>Graphic Design</option>
                    </select>
                </td>
            </tr>
    <tr>
    <td>

          <select name="order_product_type" id="type" onchange="xajax_addSizes('sizes', document.form1.type.value)">
                   <option value="">--select--</option>
                   <? foreach ($mode as $mod) { ?>
                <option value="<?= $mod?>"><?= $mod?></option>
                <? } ?>
          </select>
        
          <select name="order_product_dimensions" id="sizes" onchange="xajax_addQuantity('quantity', document.form1.sizes.value)">
             <option value="">--select--</option>
          </select>
          Quanity:
          <select name="order_product_quantity" id="quantity" onchange="xajax_addPrice('price', document.form1.quantity.value, document.form1.sizes.value,  document.form1.type.value)"><option value="">--select--</option>
          </select>
                !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                <br><?php echo "<input name='order_product_price' id='price' size='10'>"; ?>
    </form>



    </td>
    </td>
    </table>

For those of you interested, I have solved my problem by scraping info form random tutorials across the web. Here is the updated code:

<?php
require('../xjax/xajax_core/xajax.inc.php');
$xajax = new xajax();
//$xajax->configure('debug',true);
 
class myXajaxResponse extends xajaxResponse {
 
  function addCreateOptions($sSelectId, $options) {
    $this->script("document.getElementById('".$sSelectId."').length=0");
    if (sizeof($options) >0) {
       foreach ($options as $option) {
         $this->script("addOption('".$sSelectId."','".$option."','".$option."');");
       }
     }
  }
	
	function addValue($sSelectId, $data) {
 					 $this->script("document.getElementById('".$sSelectId."').value=".$data."");
           //$this->script("form1.order_product_price.value=".$data."");
       
     }
  
}
 
      $type = array('--select--','postcards','brochure / letter','invitations','grahic design');

      $sizes = array(
				'--select--'=>array('--select--'),
        'postcards'=>array('--select--','4x6','5.5 x 8.5','5.5 x 11'),
        'brochure / letter'=>array('--select--','8.5 x 11 Trifold','8.5 x 11 Half-fold','5.5 x 14 Half-fold'),
        'invitations'=>array('--select--','4.25 x 5.5 100lb Matte Color','5.5 x 8.5 100lb Gloss Color','8.5 x 12.5 100lb Matt Text'),
				'grahic design'=>array('--select--','per template design','Per Hour Graphic Design'),
      );

      $quantity = array(
        '4x6'=>array('--select--','1,000','3,000','5,000','10,000','15,000','20,000','30,000','50,000'),
        '5.5 x 8.5'=>array('--select--','1,000','3,000','5,000','10,000','15,000','20,000','30,000','50,000'),
        '5.5 x 11'=>array('--select--','1,000','3,000','5,000','10,000','15,000','20,000','30,000','50,000'),
        '8.5 x 11 Trifold'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
        '8.5 x 11 Half-fold'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
        '5.5 x 14 Half-fold'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
        '4.25 x 5.5 100lb Matte Color'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
        '5.5 x 8.5 100lb Gloss Color'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
				'8.5 x 12.5 100lb Matt Text'=>array('--select--','1,000','3,000','5,000','10,000','15,000'),
				'Per Template Design'=>array('----'),
				'Per Hour Graphic Design'=>array('----'),
				);
				
				

      // adds an option to the select 
      function addSizes($selectId, $type) {
        global $sizes;
        $objResponse = new myXajaxResponse();
        $data = $sizes[$type];
        $objResponse->addCreateOptions($selectId, $data);
				//return $objResponse->getXML();
				return $objResponse;
      	}
      function addQuantity($selectId, $sizes) {
        global $quantity;
				$objResponse = new myXajaxResponse();
        $data = $quantity[$sizes];
        $objResponse->addCreateOptions($selectId, $data);
        //return $objResponse->getXML();
				return $objResponse;
      }


			function addPrice($selectId, $quantity, $sizes, $type) {
        global $price;
				$data = '0.00';
        $objResponse = new myXajaxResponse();
				if ($type=='postcards'&&$sizes=='4x6'&&$quantity=='1,000')
				{
				      $data = '2.00';
				}
				if ($type=='postcards'&&$sizes=='4x6'&&$quantity=='3,000')
				{
				      $data = '2.00';
				}
				//etc!
        $objResponse->addValue($selectId, $data);
        //return $objResponse->getXML();
				return $objResponse;
				
				 	
}
			
			
      $xajax->registerFunction("addSizes");
      $xajax->registerFunction("addQuantity");
			$xajax->registerFunction("addPrice");
      $xajax->processRequest();
      ?>
      <?
      if (isset($_POST['Submit'])) {
        print_r($_POST);
      }
      ?>
    <html>
      <head>
      <title>AJAX Dynamic Drop Down Tutorial</title>
      <?
      $xajax->printJavascript("../xjax/");
      ?>
<script type="text/javascript">
  function addOption(selectId, val, txt) {
    var objOption = new Option(txt, val);
     document.getElementById(selectId).options.add(objOption);
   }
</script>


</head>

<body onload="document.form1.reset()">


<form action="" method="POST" name="form1" id="form1">

      <select name="order_product_type" id="type" onchange="xajax_addSizes('sizes', document.form1.type.value)">
       		<? foreach ($type as $mod) { ?>
        	<option value="<?= $mod?>"><?= $mod?></option>
        	<? } ?>
      </select>
    
      <select name="order_product_dimensions" id="sizes" onchange="xajax_addQuantity('quantity', document.form1.sizes.value)">
		 <option value="">--select--</option>
      </select>
      Quanity: 
      <select name="order_product_quantity" id="quantity" onchange="xajax_addPrice('price', document.form1.quantity.value, document.form1.sizes.value,  document.form1.type.value)">
			<option value="">--select--</option>
      </select>
			
			<br><?php echo "<input name='order_product_price' id='price' size='10' value='$product_price'>"; ?>
</form>



</td>
</td>
</table>
This question has already been answered. Start a new discussion instead.