As k
As k

Reputation: 329

get dropdown selected value

i have the following script for dropdown

<xsl:element name="optgroup">
    <xsl:for-each select="$parent/child::node">    
        <xsl:element name="option">
            <xsl:attribute name='Value' >
                <xsl:value-of select="@id"/>    
            </xsl:attribute>
            <xsl:value-of select="@nodeName"/>
        </xsl:element>
    </xsl:for-each>
</xsl:element>

i am selecting one element out of 10 elements. how to get the value of selected element on input[type=button] click event?

Upvotes: 0

Views: 1464

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167491

Well you have posted a snippet of XSLT and tagged the question as XSLT but reacting on click events in a HTML document is a job for client-side script, not for XSLT. Assuming your optgroup element is part of a select element with name="select1" and both the select and the input button are inside of a form with name="form1" you can use e.g.

<input type="button" 
       value="..." 
       onclick="alert(this.form.elements.select1.value);"/>

to alert the selected value.

Upvotes: 1

Related Questions