php description and value from drop down box?

Discussion in 'OT Technology' started by mondaynightmike, Mar 6, 2005.

  1. mondaynightmike

    mondaynightmike New Member

    Joined:
    Aug 10, 2004
    Messages:
    117,672
    Likes Received:
    0
    Location:
    DEFINITELY No *Unlinked* Cock Pics
    Hello again.

    I can get the value of a drop down box working on another php page but is there anyway i can get the description of the drop down box on another php page?

    Code:
       <select name="selectcpu" onChange="update (1)">
     	 <option> > Select A CPU <</option>
     	 <option value="40.00">Intel Celeron 320 2.4GHz</option>
     	 <option value="60.00">Intel Celeron 355 2.8GHz</option>
     	 <option value="90.00">AMD Athlon 64 3000</option>
     	 <option value="90.00">AMD Sempron 3100</option>
     	 <option value="111.00">Intel Pentium 4 3.0GHz</option>
     	 <option value="135.00">Intel Pentium 4 3.2GHz</option>
     	  <option value="145.00">AMD Athlon 64 3400</option>
       </select>
     	</td>
     	<td width="14%">
     	<image name="cpupic" src="images/clear.gif">
     	</td>
     	<td width="68%">£<input type="text" readonly name="cpuprice" size="6">
     			<input type="hidden" readonly name="cpudescription" value="$cpudiscription">
    Basically this disaplys a picture of the processor as well as it's price next to the drop down box.

    the php page i have is:
    PHP:
     <?php
     
     $cpu 
    $_GET['selectcpu'];
     
    $mb $_GET['selectmb'];
     
    $ram $_GET['selectram'];
     
    $case $_GET['selectcase'];
     
    $hd $_GET['selecthd'];
     
    $gfx $_GET['selectgraphics'];
     
    $monitor $_GET['selectmonitor'];
     
    $printer $_GET['selectprinter'];
     
    $mouse $_GET['selectmouse'];
     
    $keyboard $_GET['selectkeyboard'];
     
    $sd $_GET['selectstorage'];
     
    $cddvd $_GET['selectcddvd'];
     
    $cddvd2 $_GET['selectcddvd2'];
     
    $network $_GET['selectnetwork'];
     
    $modem $_GET['selectmodem'];
     
    $scanner $_GET['selectscanner'];
     
    $speakers $_GET['selectspeakers'];
     
    $webcam $_GET['selectwebcam'];
     
     
     
     
     print 
    "CPU Costing:$cpu $cpudescription
     <BR>
      Motherboard Costing:
    $mb
     <BR>
      Ram Costing:
    $ram
     <BR>
      Computer Case Costing:
    $case
     <BR>
      Hard Drive Costing:
    $hd
     <BR>
      Graphics Card Costing:
    $gfx
     <BR>
      Monitor Costing:
    $monitor
     <BR>
      Printer Costing:
    $printer
     <BR>
      Mouse Costing:
    $mouse
     <BR>
      Keyboard Costing:
    $keyboard
     <BR>
      Storage Device Costing:
    $sd
     <BR>
      CD\DVD drive Costing:
    $cddvd
     <BR>
     CD\DVD drive Costing:
    $cddvd2
     <BR>
      Network Card Costing:
    $network
     <BR>
      Modem Costing:
    $modem
     <BR>
      Scanner Costing:
    $scanner
     <BR>
     Speakers Costing:
    $speakers
     <BR>
      Webcam Costing:
    $webcam
     <br> 
     
     "

     
    This displays the Cost of the component but not the descritpion.

    Is it even possible to add in the description? I know i could add it to the option value but then it would not add up or display just the price is the "Price box" next to the drop down box.

    Any help would be greatly recieved!
     
  2. WERUreo

    WERUreo Imua!

    Joined:
    Oct 15, 2003
    Messages:
    566
    Likes Received:
    0
    Location:
    Daytona Beach, Florida
    This is related to what someone said in your other thread. In the html, you have:
    Code:
    <input type="hidden" readonly name="cpudescription" value=[b]"$cpudiscription"[/b]>
    That value means nothing to the browser. All it sees is "$cpudiscription", and that's all it will pass. If you have $cpudiscription set somewhere else, you'll need to enclose that with <?= ?> (ie. <?= $cpudiscription ?>, which is really just shorthand for <?php echo $cpudiscription ?>).

    Have you set yourself up with a database yet? I noticed your other thread where someone suggested you do this all in a db. That would be the simplest way, I think, to do this. You'd be able to dynamically populate the drop-down box with information that is already in the db. Then, a couple of SQL queries later, and you've got all the information you need.
     
  3. WERUreo

    WERUreo Imua!

    Joined:
    Oct 15, 2003
    Messages:
    566
    Likes Received:
    0
    Location:
    Daytona Beach, Florida
    Actually, now that I think about it, I'll bet there's a way to do it using the document object model. I'm just not sure off the top of my head how. Maybe someone more familiar with the DOM can help?
     

Share This Page