I thought I had this figured out but I was wrong. I have a xsl form that I would like to toggle or show/hide a section when a specific value is selected or present on the form. I'm limited to JavaScript and I appreciate all the help.
- When user selects option, hidden div section shows and
- When form is loaded and that value is present, div section shows
Here is the sample HTML I would like to work from to figure this out:
<select name="sbFruit" id="sbFruit" style="display:none;" title="Select your Fruit">
<xsl:variable name="sbFruit" select="Fruit" />
<xsl:for-each select="document('FRUIT_Lookups.xml')/lookups/FruitTypes/Fruit">
<xsl:variable name="optFruit" select="value" />
<option>
<xsl:if test="$sbFruit = $optFruit">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>
<xsl:attribute name="value">
<xsl:value-of select="value"/>
</xsl:attribute>
<xsl:value-of select="value"/>
</option>
</xsl:for-each>
</select>
<!-- Toggled Group when 'sbFruit' = Orange -->
<div id="AppleSubGroup" name="AppleSubGroup" style="display: none;>"
<label id="Orange_Fresh">Is the Orange Fresh?</label>
<input name="Fresh" type="radio" value="Yes" />Yes
<input name="Fresh" type="radio" value="No" />No
<br />
<label id="Orange_moldy">Is the Orange moldy?</label>
<input name="Red" type="radio" value="Yes" />Yes
<input name="Red" type="radio" value="No" />No
</div>
XML Fruit Choices:
Apple
Blueberry
Orange
Pear
or Simple HTML Version:
<select id="sbFruit" name="sbFruit">
<option>Apple</option>
<option>Blueberry</option>
<option>Orange</option>
<option>Pear</option>
</select>
<!-- Toggled Group when 'sbFruit' = Orange -->
<div id="AppleSubGroup" name="AppleSubGroup" style="display: none;>"
<label id="Orange_Fresh">Is the Orange Fresh?</label>
<input name="Fresh" type="radio" value="Yes" />Yes
<input name="Fresh" type="radio" value="No" />No
<br />
<label id="Orange_moldy">Is the Orange moldy?</label>
<input name="Red" type="radio" value="Yes" />Yes
<input name="Red" type="radio" value="No" />No
</div>
Thanks for helping!