velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Dean <richardadamd...@gmail.com>
Subject Re: Velocimacro problem evaluating variable value
Date Mon, 11 Jul 2005 11:24:38 GMT
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 <C.Townson@nature.com> 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: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message