PDA

View Full Version : List Menu


lgjavier
10-05-2005, 04:27 AM
Hi, I am Les... a newbie

need help on passing the value to listbox...
from master page(search, columnar style) i have a certain data... and once i click the link it opens my update page(entry style).. displayed the data i choose... textfield are fine... but in listmenu, it always shows the default value, instead of the data from masterpage...

hope you got what i mean... tnx in advance and God bless you all...

davidj
10-05-2005, 09:49 AM
what script language are you using

lgjavier
10-06-2005, 02:03 AM
what script language are you using
i am using PHP...

here the code i did... i added the red... but it doubled the list... i.e. the return value 2, so it displays ... but when i click the list selection... it show 2... 1... 2... 3..., instead of 1... 2... 3... only

<td bgcolor="#FFFFCC"><select name="cbo_accttype" id="cbo_accttype" title="<?php echo $row_rsUpdate['AcctType']; ?>">
<option selected><span style='color:red'><?php echo $row_rsUpdate['AcctType']; ?></span></option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>

thanks again and God bless you.

davidj
10-06-2005, 10:13 AM
ok
i assume you are passing a record ID through $_POST to your querystring on the update page

to set a dropdown to a specific value you need to use strcmp() function
(StringCompare)

example...



<select name="company" >

<option value="v1"<?php if (!(strcmp($variable, 'v1'))){echo "SELECTED";} ?>
>value1</option>

<option value="v2"<?php if (!(strcmp($variable, 'v2'))){echo "SELECTED";} ?>
>value2</option>

<option value="v2"<?php if (!(strcmp($variable, 'v3'))){echo "SELECTED";} ?>
>value3</option>

</select>


using strcmp you are looking for an exact comparison between the two arguments $variable, 'v1' then if boolean true echo SELECTED

you can pass the variable from your first page and setting it in this page
e.g
$variable = $_POST['txtfieldName'];

or if you are querying a db from this page you could just set $variable with the contents of $row_recordsetname['mysql_field'];

$variable = $row_recordsetname['mysql_field'];

If you tell me exactly how you are passing the data from page 1 > page 2 i will be able to help more

lgjavier
10-08-2005, 02:39 AM
Thanks davidj... i'll try this...
till next time... ingat (means take care), enjoy and God bless you.