Subject: [xsl] Creating a html <select> dropdown menu in XSL, where the attribute of an XML element is the selected value when page loads From: Martin Jackson <martsonjackin@xxxxxxxxx> Date: Thu, 17 Dec 2009 17:59:23 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] sorting a table based on , Michael Kay | Thread | Re: [xsl] Creating a html <select> , David Carlisle |
Re: [xsl] retaining entity declarat, a kusa | Date | Re: [xsl] retaining entity declarat, a kusa |
Month |