2
<select name="n" onchange="if(this.selectedIndex != 0) window.location = this.options[this.selectedIndex].value">
  <option value="url&amp;param={param}">
     <xsl:if condition>
       <xsl:attribute name="selected">true</xsl:attribute>
     </xsl:if>
  </option>
</select>

The code above works fine, it passes selected option to url. The only problem is that when the parameter contains '&' sign in between. How do I pass a parameter with a value like 'A & B'? urlencode seems not helpful? Thanks for your time!

Weihui Guo
  • 3,669
  • 5
  • 34
  • 56

1 Answers1

0

Tried urlencode(), but it returns double escaping error. Note that this question is not about to simply encode the whole url, but to escape some Special Characters for passing parameters. I had another situation, in which a parameter value has '+' sign in the string. I figured that it's probably better to show the string but return a nameid something as the value, which is int. My option value changed to something like this:

  <select onchange="if(this.selectedIndex != 0) window.location = this.options[this.selectedIndex].value">
    <option value="" selected="selected"><xsl:value-of select="/A/D/NAME"/></option>
    <xsl:for-each select="/A/B/C">                  
     <option value="URL&amp;Name={NAME}&amp;ID={ID}"
      <xsl:if test="NAME=/A/D/NAME"><xsl:attribute name="selected">true</xsl:attribute></xsl:if>
      <xsl:value-of select="NAME"/>
     </option>
    </xsl:for-each>
  </select>

The url now have the Id as the parameter2 matching the parameter1(Name). And I can use this Id to search the database and return the string(Name) to show again. This doesn't directly answer the question, but does provide a workaround.

Weihui Guo
  • 3,669
  • 5
  • 34
  • 56