client side problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zuzupus
Forum Commoner
Posts: 70
Joined: Thu Jul 17, 2003 4:54 am

client side problem

Post by zuzupus »

hi,
i got problem regarding client side combo boxes as u see kunde combo link associated with projekt combo,i mean to say on change kunde i can see associated link in project so what i did i use javascript to achieve this,is it possible to use php to get achieve this one as u can see these kunde and projekt values r coming from database but i hard coded in javascript to get associated value

for eg. Kunde having values
apple
mango
pine
and when change on apple u get values in project like
tasty
sweet
nutitious

for more clear http://www.javascriptkit.com/script/cut183.shtml

is it possible to use PHP to achieve this as i dont want to hard code the projekt values in javascript like i did
group[0][0]=new Option("tasty","tatsy");
group[0][1]=new Option("mango","mango");
group[0][2]=new Option("nutitious","nutitious");

Code: Select all

<td  align="center">
<select name="kunde" onchange="redirect(this.options.selectedIndex)">
<? foreach($kunden as  $value) { ?>
<option value="<?= $value ?>" <? if ($HTTP_POST_VARS['kunde'] == $value){ echo "SELECTED";}?>><?= $value ?></option>
 <? } ?>
 </select>
 </td>

<td  align="center">
<select name="projekt">
 <? foreach($hprojekt as  $value) { ?>
<option value="<?= $value ?>" <? if ($HTTP_POST_VARS['projekt'] == $value){ echo "SELECTED";}?>><?= $value ?></option>
<?  } ?>
 </select>
</td>
<script language="javascript" src="doublecombo.js"></script>

please let me know is it possible to get this task done by PHP as this one is server side

thanks
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

If you're willing to chenge pages every time you select a different item in the combo box, then you can do it in PHP, but it would be much easier to do it in javascript as you said, with the values hard-coded into the page by PHP.
zuzupus
Forum Commoner
Posts: 70
Joined: Thu Jul 17, 2003 4:54 am

Post by zuzupus »

thanks alot so i can safely hardcode safely in javascript
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

Unless you've got passwords or other sensitive data, then hard-coding the values in javascript is perfectly safe (security-wise). If you mean "safe" as in fast, efficient and simple, then yes, it should be fast and efficient enough. (.. unless javascript has, you know, 6 levels of select-boxes, with humongous multidimensional arrays :))
Post Reply