Page 1 of 1

client side problem

Posted: Tue Jul 22, 2003 5:58 am
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

Posted: Tue Jul 22, 2003 5:59 am
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.

Posted: Tue Jul 22, 2003 6:02 am
by zuzupus
thanks alot so i can safely hardcode safely in javascript

Posted: Tue Jul 22, 2003 6:05 am
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 :))