views:

79

answers:

1

My backend accepts comma delimited id values "11,12,13". On the front end I have a check list that allows multiple selection and posts the following.

someurl.com?id=11&id=12&id=13

How do I use $_GET for multiple instances of ID, format it into a comma seperated string? Or alternatively, is there a better way to force checklists to submit the form in the format I want?

Now back to the front end, I use XSLT to determine whether or not to check an item to remebr it's previous state.

    <xsl:choose>
    <xsl:when test="$id = *">
        <option selected="selected">
            <xsl:value-of select="*"/>
        </option>
    </xsl:when>
    <xsl:otherwise>
        <option>
            <xsl:value-of select="*"/>
        </option>
    </xsl:otherwise>
</xsl:choose>

This is fine when just one option is selected but with multiples, how would you handle multiple instances of that $id value in the url?

Any help and solutions much appreciate.

+1  A: 

I don't use php all that much, but I believe you want ?id[]=11&id[]=12&id[]=13 to get the array [11,12,13] in the id parameter.

I'm afraid the description of the xslt problem is too brief for me to understand. First of all, I don't understand why you want to set the selected attribute in the frontend in the first place. Then, I'd suggest DRY:

<option>
  <xsl:if test='...'>
    <xsl:attribute name='selected' value='"selected"'/>
  </xsl:if>
  <xsl:value-of select='*'/>
</option>

As for the test itself, what do you get from the server when selecting multiple elements in a way the server understands? Would a simple

<xsl:if test="contains(concat(',', $ids, ','), concat(',', *, ','))">

work?

Christopher Creutzig