[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Creating a html <select> dropdown menu in XSL, where t
Hi all, I'm trying to make a page where I can edit the data (like name and date of birth) of a person in a data base. I have a php page which gets the data for the person you have chosen to edit from the data base and generates an XML element that looks like this: <PERSON ID='$id' FIRSTNAME='$firstname' LASTNAME='$lastname' DAY='$day' MONTH='$month' YEAR='year'></PERSON> I want to use XSL to generate a html page, that have three dropdown menus for Day, Month and Year. I want them to display the correct data from the data base when the page loads. For example, if someone is born on the 3rd, I want the Day dropdown menu, which consists of numbers 1-31 to display "3" In html this is done by giving one of the <option> elements in the <select> menu the attribute "SELECTED", like this: <select> <option value="1">1</option> <option value="2">2</option> <option value="3" SELECTED>3</option> <option value="4">4</option> ... </select> Earlier, I didn't use XSL and instead just generatead html directly in my php document. Then the code below did the trick. What would the xsl equivalent look like? for($current_day=1; $current_day <= 31; $current_day++) { echo "<option value='$current_day'"; if($current_day==$day) { echo " SELECTED"; } echo ">$current_day</option>"; } How can this be done in XSL? As far as I understand, the existing loop functions in XSL, like <xsl:for-each> are used to loop over a number of elements? I , on the other hand, want to output a number of html <option> elements, where the value increments for each iteration, and compare them all to the same attribute of a certain XML <person> element, and (when I get a match) output the html <option> element with "SELECTED" added. Greetings, Martin Jackson
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|