How to retrieve the selection list
The following is my selection list, where should i put the <dtml-var custcountry> in order to display the selected result. <select name="custcountry" size="1" tabindex="9" style="HEIGHT: 22px; WIDTH: 293px"> <option value="....."selected>Please select a country</option> <option value="Australia">Australia</option> <option value="Cambodia">Cambodia</option> <option value="Canada">Canada</option> <option value="China">China</option> <option value="Colombia">Colombia</option> <option value="Denmark">Denmark</option> <option value="France">France</option> <option value="Germany">Germany</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Hong Kong S.A.R.">Hong Kong S.A.R.</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Italy">Italy</option> <option value="Japan">Japan</option> <option value="Korea">Korea</option> <option value="Korea, North">Korea, North </option> <option value="Macau S.A.R.">Macau S.A.R.</option> <option value="Malaysia">Malaysia</option> <option value="United Kingdom">United Kingdom</option> <option value="United States">United States</option> </select> Thank You!
On Tuesday 09 January 2001 16:01, Angietel wrote:
The following is my selection list, where should i put the <dtml-var custcountry> in order to display the selected result.
Ooh... this one hurts.. (o8 You have to put "SELECTED" on the 'option' tag you want to be default. This means iterating over your list with something like: <dtml-in CountryList> <option <dtml-if "_['sequence-item']==custcountry"> SELECTED</dtml-if> value="<dtml-var sequence-item>"><dtml-var sequence-item> </dtml-in> If you don't already have the country list in an object somewhere, I recommend adding a "lines" type property to either that object, or an appropriate folder, and put them in there. And remember... if "custcountry" doesn't exist.. this will break... do putting a: <dtml-unless custcountry> <dtml-call "REQUEST.set('custcountry',' ')"> </dtml-unless> at the top of the page won't hurt.
<select name="custcountry" size="1" tabindex="9" style="HEIGHT: 22px; WIDTH: 293px">
<option value="....."selected>Please select a country</option>
<option value="Australia">Australia</option> <option value="Cambodia">Cambodia</option> <option value="Canada">Canada</option>
8< *snip* >8
</select>
Thank You!
Have a better one, Curtis Maloney.
At 13:01 9-1-01 +0800, Angietel wrote:
The following is my selection list, where should i put the <dtml-var custcountry> in order to display the selected result.
You don't have to, as soon as one option is selected you're variable custcountry gets the value from <option value="Canada"> and the text between <option value="Canada"> and </option> is being displayed. <option value="Canada">Canada</option> ^ ^ If you have you're countries in a database you can let sql generate an option list in stead of typing all the options. Something like this: <select name="custcountry"> <dtml-in "select_country(REQUEST)"> <option value='<dtml-var country_field>'><dtml-var country_field></option> </dtml-in> </select> Where select_country is a sql-method like: select country_field from COUNTRY Regards, Diny
<select name="custcountry" size="1" tabindex="9" style="HEIGHT: 22px; WIDTH: >293px">
<option value="....."selected>Please select a country</option>
<option value="Australia">Australia</option> <option value="Cambodia">Cambodia</option> <option value="Canada">Canada</option> <option value="China">China</option> <option value="Colombia">Colombia</option> [...] <option value="United States">United States</option> </select> Thank You!
DIVA, Faculty of Veterinary Medicine Utrecht University, The Netherlands http://www.vet.uu.nl
participants (3)
-
Angietel -
Curtis Maloney -
Diny van der Donk