Re: [xsl] getting values from controls with ids

Subject: Re: [xsl] getting values from controls with ids
From: "Prasad Akella" <avlnprasad@xxxxxx>
Date: Thu, 17 Feb 2005 12:13:17 +0100
thanks for this reply it looks right, i am hand coding my javascript. i would provide a snippet as to what it looks like maybe u can suggest an alternative - 

<xsl:template match=xforms:input>
<xhtml:input name="{@ref}" id="{generate-id(.)}"/>

now let us assume that the above template matches every xforms:input control and replaces an xhtml input for that with this unique id. but i want to access this value in the xhtml control from the user form and for that in my javascript i have to use something like 

    Questionlist[1][4] = document.getElementById('Marks').value;

now in this above snippet, i am using the ID - Marks which actually isthe id i have give to an xhtml control but i have some controls whihc are repeating for example

i have a switch-case in xforms which when generated in a generic way has problems as i am using div like
<xsl:template match="xforms:switch">            
            <xsl:for-each select="xforms:case">
                <xsl:variable name="caseId" select="@id"/>
                <xsl:variable name="disp">
                        <xsl:when test="@selected ='true()'">visible</xsl:when>
                <xhtml:div id="{$caseId}" style="LEFT:5px; POSITION:relative; TOP:5px; VISIBILITY:{$disp}; Z-INDEX:0">
                    <xsl:copy-of select="@*"/>
the problem is i have cases like

Blank, True or False, Explain, Radiobutton and Checkbox. now depending upon what hte user has selected his question type to be, i am making that respective div visible in the javascript like

 function toggle(caseType){                        
                        var w = document.getElementById(caseType).selectedIndex;
                        var name = document.getElementById(caseType).options[w].value;                       

this is a function being called from a select control
the problem is:  i have all the controls rendered and they are just hidden or visible 
now when i say 

its returning me only the first value in one of the xhtml control which is Blank, the rest of all are not returned although that case is not valid. this is understandable as my code generates the controls in a generic way and my ids are repeating whcih should not happen. but i see no other way as to how to solve this problem. my cases are being rendered out of which only one would b eactive at any point of time and the controls are repeating with teh same name and id. thus my shift to generate-id() but with that i am not able to access these controls. please help me

and i do not know how the xsl generated the javascript. i am having lot of trouble integrating both of them and the values are not exchangable between both. that is understandable. i do not know how to make use of the value of avariable in xsl in javascript or vice versa. any help in this regard would be greatly welcome.

thankyou for your time

with regards,
Prasad Akella

xsl-list@xxxxxxxxxxxxxxxxxxxxxx schrieb am 17.02.05 11:55:38:
> It isn't clear from your question how you are producing your javascript.
> If it is being written out by the same XSLT process then generating
> correct javascript expression using the generate-id() call is easy, you
> just call generate-id again (on the same node).
> If you are hand writing the javascript or generating it in a different
> process, you don't want to use generate-id for your ids as they are
> essentially unpredicatble strings. instead use somethong like
> <xsl:attribute name="id">
>  <xsl:text>id</xsl:text>
>  <xsl:number level="any"/>
> </xs:attribute>
> which gives you predicable ids id1, id2, id2, ... which you can then use
> from elesewhwere.
> David
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> ________________________________________________________________________

Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail:

Current Thread