473,397 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Populating a selectbox with selected value???

Si
I'm going round in circles trying to set a value as selected in a
dropdown box on an ASP page.
Basically this is the XML I've got:

<rs:data>
<z:row DirectorateID="67" DirectorateName="CEO"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="68" DirectorateName="eIS"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="69" DirectorateName="S&C"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="70" DirectorateName="F&CR"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="71" DirectorateName="O&S"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="73" DirectorateName="HR"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="74" DirectorateName="SM&C"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="75" DirectorateName="F&CS"
rsName="rc_listDirectorates_sp" />
</rs:data>
-<rs:data>
<z:row AuthorID="11" FullName="Jo West" FirstName="Jo"
LastName="West" DateCreated="2006-12-11" theDirectorateID="74"
rsName="rc_listUsers_sp" />
</rs:data>

The top <rs:datapopulating the dropdown box and it's 'selected'
value being determined by the DirectorateID in the next <rs:data>

At the minute I'm think ing of XSLT something like:

<xsl:template match="rs:data[z:row/
@rsName='rc_listDirectorates_sp']">
Directorate:
<select name="Directorates">
<xsl:apply-templates />
</select>
</xsl:template>

<xsl:template match="rs:data/
z:row[@rsName='rc_listDirectorates_sp']">
<xsl:choose>
<xsl:when test="@DirectorateID !=
@DirectorateID">
<option
value="{@DirectorateID}">
<xsl:value-of
select="@DirectorateName"/>
</option>
</xsl:when>
<xsl:otherwise>
<option selected="selected"
value="{@DirectorateID}">
<xsl:value-of
select="@DirectorateName"/>
</option>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

but is this any good? Is this even possible?!?

Sorry if this is a stupid question but I'm a DBA by trade.

Thanks

Jan 30 '07 #1
1 1923

On Jan 30, 1:03 pm, "Si" <si.dow...@gmail.comwrote:
<rs:data>
<z:row DirectorateID="67" DirectorateName="CEO"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="68" DirectorateName="eIS"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="69" DirectorateName="S&C"
Not well-formed.
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="70" DirectorateName="F&CR"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="71" DirectorateName="O&S"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="73" DirectorateName="HR"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="74" DirectorateName="SM&C"
rsName="rc_listDirectorates_sp" />
<z:row DirectorateID="75" DirectorateName="F&CS"
rsName="rc_listDirectorates_sp" />
</rs:data>
-<rs:data>
You seem to have forgotten something in there.
<z:row AuthorID="11" FullName="Jo West" FirstName="Jo"
LastName="West" DateCreated="2006-12-11"
theDirectorateID="74" rsName="rc_listUsers_sp" />
</rs:data>

The top <rs:datapopulating the dropdown box and it's
'selected' value being determined by the DirectorateID in
the next <rs:data>

[...]
<xsl:when test="@DirectorateID != @DirectorateID">
Here's your problem. Precisely when do you expect this
condition to be true? You're comparing a value to itself,
so of course this will always be false. (As a matter of
fact, I remember a copy protection system for floppy disks
from the 80s that was doing exactly that and expecting true
as a proof that the floppy disk contained a legitimate copy
of the software. AFAIR, the catch was that you could have
two sectors with the same number--but different contents--
on a track, so with proper timing you could read the
seemingly same sector twice and get different results.)

Anyway, what you really need is current(). Read a little
about it, and it should be immediately obvious how to solve
your problem.
but is this any good?
Does it work? (No, it doesn't, but you should've told us
that. And it would be nice to mention what exactly doesn't
seem to work.)
Is this even possible?!?
Certainly. The following works on my test document:

<xsl:template
match=
"
rs:data[z:row/@rsName='rc_listDirectorates_sp']
">
<xsl:text>Directorate: </xsl:text>
<select>
<xsl:apply-templates/>
</select>
</xsl:template>
<xsl:template
match=
"
rs:data/z:row[@rsName='rc_listDirectorates_sp']
">
<option>
<xsl:attribute name="value">
<xsl:apply-templates select="@DirectorateID"/>
</xsl:attribute>
<xsl:apply-templates
select=
"
../../rs:data/z:row
[@rsName='rc_listUsers_sp']
[@theDirectorateID=current()/@DirectorateID]
" mode="selected"/>
<xsl:apply-templates select="@DirectorateName"/>
</option>
</xsl:template>
<xsl:template
match=
"
rs:data/z:row
[@rsName='rc_listUsers_sp']
[@theDirectorateID]
" mode="selected">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:template>
Sorry if this is a stupid question but I'm a DBA by
trade.
Not at all a stupid question, but you should've checked
what you are posting to the USENET.

--
Pavel Lepin

Jan 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tole | last post by:
hi all, i've got a selcetbox (multiple) which is filled by javascript. only problem is that i have aprox 1000 options to add to that select, and that adding lasts for 5-6 seconds. Even...
5
by: bigbuddha | last post by:
Hello, I have a form two multiple selectboxes. Firs one with options, second one empty I need to select a few items and hit an "add" button to get them in the second one. Preferably a "remove"...
7
by: Erwin Moller | last post by:
Hi, situation: I have a long list of options in multiple selectbox. The selectbox gets a scrollbar in that situation. Does anybody know if it is possible to scroll through the options with...
2
by: John Ninan | last post by:
I am creating Dynamic Usercontrol in Asp.net application. In this application I have a combobox(aspx Page). Which contains various items. Based on item selected I am dynamically populating...
1
by: shankwheat | last post by:
I've been using this little script to change the <a href=""></a> value of a link which works well. <script language="javascript" type="text/javascript"> function ordering(sorder) { var link =...
4
by: shankwheat | last post by:
I'm passing a string like 'Div3,Div4' to use as options in a selectbox but I need the text the user sees in the box different from the values. My code populates the values in the selectbox...
1
by: evanburen | last post by:
I have 2 selectboxes and I want to change the values in the second based on the first one. I found a few examples of this but none of them quite do what I want. Could someone get me started on...
4
by: ramchml | last post by:
i have two select boxes.based on the selected value in one select box it show the maximum options in the other select box in next page.i used javascript onclick function.for first time it shows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.