Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Dynamic listing in php with javascript


241

Recommended Posts

Thank you all for any input on this.

 

Here is the outline, I need to get an outputed string from the chosen radio button to use for a set of if else statement.

 

the code so far is this:

<?php
// Wolfen initial product choice radio button - start
          $radio_html = '<table border="0" cellspacing="0" cellpadding="2"><tr>';
 $products_choice_query = tep_db_query("select products_choice_id, products_choice_name from " . TABLE_PRODUCTS_CHOICE . " 

order by products_choice_id");
          $checked = true;
          while ($products_choice_array = tep_db_fetch_array($products_choice_query)) {
            $radio_html .= '<td class="main">';
            $radio_html .= tep_draw_radio_field('id[' . $products_choice['products_choice_id'] . ']', 

$products_choice_array['products_choice_id'], $checked, 'onChange=""');
            $checked = false;
            $radio_html .= $products_choice_array['products_choice_name'];
            $radio_html .= '</td>';
          }
          $radio_html .= '</tr><a href="attribute_info/products_choice.php" target="blank"><img src="images/i.gif" 

border="0"></a></table>';
?>

          <tr>
            <td class="main"><?php echo $products_choice['products_choice_name']; ?></td>
 </tr>
 <tr>
            <td class="main"><?php echo $radio_html;  ?></td>
          </tr></table>
  
<?php
// Wolfen initial product choice radio button - end
if ($products_choice['products_choice_id'] = '1') {

 

which gives three radio buttons pulled from an array created from the table in the database which has three entries.

 

The table consists of products_choice_id and products_choice_name

 

what I want to do is have someone select using the radio buttons and depending on the selection as shown at the end of the

 

code with the

if ($products_choice['products_choice_id'] = '1') {

another set of values will be presented.

 

The if part is there as a representation that the next section of code will be the if else statements.

 

any help you can give on this would be appreciated.

 

 

Further blurb::

 

I am looking now at possible use of a javascript function for the onChange, onSelect or onClick

 

as you can see the end code for the radio button is incomplete

 'onChange=""');

 

To give you a little more details, this code is to be used on the product_info.php

 

This would be used where there are lots of different attributes available.

 

The idea of the radio buttons is to cut down on the attributes that are initially shown by giving an initial set of radio buttons, when a selection is made using the radio buttons, this then shows the specific attributes for that selection as not all attributes will be used for all choices.

 

Example: three radio buttons called 1, 2, 3

 

radio 1 only requires attributes showing 1 drop menu with a choice of 3

 

radio 2 requires 3 drop menus with choices from each dop menu and also requires 2 checkboxes and a text input.

 

radio 3 requires 4 drop menus 3 radio buttons 2 check boxes and a text area input.

 

to show the combination of all of these to a user and then get them to make a choice would be to confusing, that is where the initial 3 radio button choice comes into play, therefore the user is only presented with the appropriate attributes for the initial choice rather that all attributes for all choices.

No longer giving free advice. Please place deposit in meter slot provided.  Individual: [=] SME: [==] Corporation: [===]
If deposit does not fit one of the slots provided then you are asking too much! :P

Is your Osc dated try Phoenix  raising oscommerce from the ashes.

Link to comment
Share on other sites

  • 3 weeks later...

The questions are:

 

1. what is required in the onChange part at present I have choose()

2. What javascript is required to make this function.

 

 

The simplified html derived from the php previously posted.

 

 

 

<table border="0" cellspacing="0" cellpadding="2">
           <tr>
  <td class="main"><form name="cart_quantity" method="post" action="">
           <table border="0" cellspacing="0" cellpadding="2">
  <tr>
           <td class="main">
      <label><input type="radio" name="choice" value="1" CHECKED onChange="choose()">Car Mascot</label> 
   <label><input type="radio" name="choice" value="2" onChange="choose()">Ornament</label> 
   <label><input type="radio" name="choice" value="3" onChange="choose()">Trophy</label>
  </td> 
  </tr><a href="attribute_info/products_choice.php" target="blank"><img src="images/i.gif" border="0"></a>
  </table></form>
  </td>
  </tr>

  </table>

 

if choice 1 Car mascot is selected I need it to show this code on the same page

 

<table border="0" cellspacing="0" cellpadding="2">
           <tr>
             <td class="main">Car Mascot:</td>
             <td class="main"><select name="id[2]"><option value="3">Select a finish</option><option value="4">Bronze (+?39.00)</option><option value="5">Chrome plated (+?39.00)</option><option value="6">Enamelled (+?87.00)</option></select><a href="attribute_info/option_2.php" target="blank"><img src="images/i.gif" border="0"></a></td>
           </tr>
     </table>

 

if choice 2 Ornament is selected I need it to show this code on the same page

 

<table border="0" cellspacing="0" cellpadding="2">
           <tr>
             <td class="main">Ornament:</td>
             <td class="main"><select name="id[1]"><option value="1">Select a finish</option><option value="2">Silver plated (+?45.00)</option></select><a href="attribute_info/option_1.php" target="blank"><img src="images/i.gif" border="0"></a></td>
           </tr>
     </table>

 

if choice 3 Trophy is selected I need it to show this code on the same page

 

<table border="0" cellspacing="0" cellpadding="2">
           <tr>
             <td class="main"><select name="id[3]"><option value="7">Select a finish</option><option value="8">Bronze (+?39.00)</option><option value="9">Chrome plated (+?39.00)</option><option value="10">Enamelled (+?87.00)</option></select><a href="attribute_info/option_3.php" target="blank"><img src="images/i.gif" border="0"></a><select name="id[4]"><option value="11">Select a mount</option><option value="12">Large thick Oak (+?12.00)</option><option value="13">Large Mahogany plinth (+?17.00)</option><option value="14">Rough cut Welsh Slate (+?28.00)</option><option value="15">Welsh Slate 5in x 3in x 1.5in (+?19.00)</option></select><a href="attribute_info/option_4.php" target="blank"><img src="images/i.gif" border="0"></a></td>
           </tr>
           <tr>
             <td class="main"><input type="checkbox" name="id[5]" value="16">(+?14.10) <a href="attribute_info/option_5.php" target="blank"><img src="images/i.gif" border="0"></a><input type="text" name ="id[txt_6]" size="32" maxlength="32" value="">  <a href="attribute_info/option_6.php" target="blank"><img src="images/i.gif" border="0"></a></td>
           </tr>
     </table>

No longer giving free advice. Please place deposit in meter slot provided.  Individual: [=] SME: [==] Corporation: [===]
If deposit does not fit one of the slots provided then you are asking too much! :P

Is your Osc dated try Phoenix  raising oscommerce from the ashes.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...