JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 15th, 2004, 09:54 AM
241 241 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 241 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 34 sec
Reputation Power: 0
Dynamic listing in php with javascript onChange or onClick

OK firstly Newbie alert!
Next if this is in the wrong forum could you please move to the correct forum.
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:
Code:
<?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></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
Code:
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

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

I have a situtation where there is a lot 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 o 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.

Reply With Quote
  #2  
Old October 15th, 2004, 03:36 PM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Canada
Posts: 330 Viper_SB User rank is Private First Class (20 - 50 Reputation Level)Viper_SB User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 5 h 3 sec
Reputation Power: 15
You can't do it with PHP, PHP is a server side language and once run won't respond to user input until the user either changes pages or submits a form.

Your best bet is javascript, but still not sure what exactly is your question besides if it'll work in PHP or not.

Reply With Quote
  #3  
Old October 16th, 2004, 11:10 AM
241 241 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 241 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 34 sec
Reputation Power: 0
Quote:
Originally Posted by Viper_SB
You can't do it with PHP, PHP is a server side language and once run won't respond to user input until the user either changes pages or submits a form.

Your best bet is javascript, but still not sure what exactly is your question besides if it'll work in PHP or not.
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.

Code:
<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>&nbsp;
	<label><input type="radio" name="choice" value="2" onChange="choose()">Ornament</label>&nbsp;
	<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
Code:
<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
Code:
<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
Code:
<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>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Dynamic listing in php with javascript onChange or onClick


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap