Chris,
Firstly, your HTML syntax is not correct (selected="selected") but also,
remember that the "==" causes an object compare - you should force a string
compare by using the following;
#if($selected.equalsIgnoreCase("Dr")) selected #end
Steve
-----Original Message-----
From:
[EMAIL PROTECTED]
.org
[mailto:[EMAIL PROTECTED]
a.apache.org]On Behalf Of Richard Dean
Sent: 11 July 2005 12:25
To: Velocity Users List
Subject: Re: Velocimacro problem evaluating variable value
Hi Chris,
Think it might just be that you are missing an '=' sign :
#if($selected == "Dr") selected = "selected" #end
rather than
#if($selected = "Dr") selected= "selected" #end
Richard
On 7/11/05, Townson, Chris <[EMAIL PROTECTED]> wrote:
>
> Hi -
>
> In my VM_global_library, I have the following simple macro to create a
> drop-down list of name titles for HTML forms:
>
> #*
> * makeTitlesDropDown
> *
> * Macro to create a select + options drop-down list of name titles
> * Does not include a label for the select box, because we might want this
> elsewhere
> * Takes three parameters:
> * var STRING $id: value of the id for the select box
> * var STRING $name: value of the name attribute for the select box
> * var STRING $selected: the name title value to be set as pre-selected
> *#
> #macro ( makeTitlesDropDown $id $name $selected )
> <select id="$id" name="$name">
> <option value="Dr"#if($selected = "Dr")
> selected="selected"#end>Dr</option>
> <option value="Prof"#if($selected = "Prof")
> selected="selected"#end>Prof</option>
> <option value="Mr"#if($selected = "Mr")
> selected="selected"#end>Mr</option>
> <option value="Mrs"#if($selected = "Mrs")
> selected="selected"#end>Mrs</option>
> <option value="Miss"#if($selected = "Miss")
> selected="selected"#end>Miss</option>
> <option value="Ms"#if($selected = "Ms")
> selected="selected"#end>Ms</option>
> </select>
> #end
>
> I then call this with the following:
> #makeTitlesDropDown ( "title" "title" "Mr" )
>
> The select list comes out fine, except for the fact that the third
> parameter
> - which is used to pre-select a particular option - is not being picked up
> /
> evaluated as expected.
>
> Is there anything really obvious that I am doing wrong here?? :D
>
> Thanks,
>
> Chris
>
>
>
****************************************************************************
****
> DISCLAIMER: This e-mail is confidential and should not be used by anyone
> who is
> not the original intended recipient. If you have received this e-mail in
> error
> please inform the sender and delete it from your mailbox or any other
> storage
> mechanism. Neither Macmillan Publishers Limited nor any of its agents
> accept
> liability for any statements made which are clearly the sender's own and
> not
> expressly made on behalf of Macmillan Publishers Limited or one of its
> agents.
> Please note that neither Macmillan Publishers Limited nor any of its
> agents
> accept any responsibility for viruses that may be contained in this e-mail
> or
> its attachments and it is your responsibility to scan the e-mail and
> attachments (if any). No contracts may be concluded on behalf of Macmillan
> Publishers Limited or its agents by means of e-mail communication.
> Macmillan
> Publishers Limited Registered in England and Wales with registered number
> 785998
> Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS
>
>
****************************************************************************
****
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]