This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: Problems with form tag in javascript in an xml/xsl setup


> > I have a situation where I have an xsl style sheet, that 
>contains the the
> > contents for an HTML table of many fields, some text boxes, 
>some select
> > boxes, etc.
> > This xsl file also contains a javascript and a form tag.
> > ...
> > The problem is that the xsl that has the html for the form 
>tag, is not
>able
> > to be seen in the javascript that is in the same xsl file.
> >
> > It is as if there is no form.
>
-- very common errors in this area is that people generally forget 
to refer to the variables( input variables as in textfeild name 
)through the form name
check if the textfield name is reffered as 
formname.textfieldname.
If this does not solve the problem, try executing the HTML part in 
the browser. if that works fine then this should work fine..
HTH

--

On Tue, 05 Mar 2002 Thomas B. Passin wrote :
>[Rochester, Dean]
>
> > I have a situation where I have an xsl style sheet, that 
>contains the the
> > contents for an HTML table of many fields, some text boxes, 
>some select
> > boxes, etc.
> > This xsl file also contains a javascript and a form tag.
> > ...
> > The problem is that the xsl that has the html for the form 
>tag, is not
>able
> > to be seen in the javascript that is in the same xsl file.
> >
> > It is as if there is no form.
>
>There are too many unknowns here.
>
>1) Are you transforming the data in the browser, and is the 
>browser Internet
>Explorer?
>
>2) I don't see anywhere that your javascript function is getting 
>called.
>Are you sure that it is?
>
>3) You use document.write() in your function.  Normally, that 
>replaces the
>document with a new one containing whatever you document.write().  
>One
>effect of this is to get rid of any javascript that had been 
>defined in the
>document.  The usual ways to avoid this are to  either open 
>another window
>and write to that, or to use frames, put the javascript into the 
>head
>element of the frameset document, and write to one of the 
>frames.
>
>If your function actually runs, how have you prevented it from 
>destroying
>itself in this manner?
>
>4) Does the browser indicate any errors?
>
>5) You can capture the xml by using an identity stylesheet.  This 
>should
>show what the xml would have looked like if it had been a real 
>document.
>Try to get the xml that way, save to a file (maybe by selecting 
>the entire
>window and copying to the clipboard), then transform it with your 
>stylesheet
>and see if the resulting html works the say you expect.
>
>If you still have a problem after you have answered all these 
>things, let us
>know, being more precise about exactly what the nature of the 
>problem is.
>
>Tom P
>
> >
> > The xml data is dynamically built xml stack, not an xml 
>file.
> >
> > In the xsl style sheet is a javascript that is to walk through 
>the form
> > looking for elements on the form that match a passed in 
>className and then
> > check the values of these fields.  If they are null it pops up 
>an alert.
> >
> >
> > I named the form  mainform.
> >
> > I have tried things like
> >
> > var form1 = document.forms[0];
> >
> > then print out the name of form1 and I get nothing.
> >
> > Is there a problem with the form not actually being in a 
>regular html
>file,
> > that the javascript, since it is in the xsl file, it does not 
>know how to
> > handle the form?
> >
> > When the page displays, I can see the form just fine, but I 
>can not get
>the
> > if null conditional stuff to work, because it does not think 
>there is a
> > form.
> >
> > I can not include the xml but I can include the xsl
> >
> > ------------------------------------------ xsl file
> > -------------------------------------------------
> >
> > // this is the function where it walks through the forms 
>elements
> > // elClass is the passed in className that is being searched 
>for
> > function editTab(elClass)  {
> >
> >
> >    var form1 = document.forms[0];
> >
> >    var elemClass = elClass;
> >
> >
> >
> >
> >
> >    var elements=new Array()
> >    var form,element,f,e
> >    for (f in document.forms){
> >        form=document.forms[f]
> >        document.writeln("<br>form name = " + form.name + 
>"</br>");
> >        document.writeln("<br>f = " + f + "</br>");
> >        for (e in form.elements){
> >            element=form.elements[e]
> >            if (element.className == elClass){
> >                elements.push(element.value)
> >            }
> >        }
> >    }
> >
> >
> >
> >
> >    if(elemClass == "demo") {
> >      document.writeln("<br>elements.length = " + 
>elements.length +
>"</br>");
> >      document.writeln("<br>elemClass = " + elemClass + 
>"</br>");
> >      document.writeln("<br>all.length = " + allTags.length + 
>"</br>");
> >
> >    }
> >
> >   //get a list of all the tags in the form
> >   for (var intLoop = 0; intLoop < elements.length; intLoop++) 
>{
> >       //document.writeln("<br>elemClass = " + elemClass + 
>"</br>");
> >       //198 sertw;
> >       //if(form1.elements[intLoop].className){
> >       //   if (form1.elements[intLoop].className == elemClass) 
>{
> >       if (elements[intLoop].className == elemClass) {
> >         // save edit parameters
> >         strEdit = elements[intLoop].getAttribute('edit');
> >
> >
> >           // if edits, perform them
> >           if (strEdit != null) {
> >               //document.writeln("<br>strEdit = " + strEdit + 
>"</br>");
> >               //document.writeln("<br>intLoop = " + intLoop + 
>"</br>");
> >               strFldName = 
>elements[intLoop].getAttribute('title') + " ("
>+
> > elements[intLoop].getAttribute('name') + ")";  // save field 
>name
> >               // parse edits
> >               strResult =
> > strEdit.match(/[a-zA-Z]+\([a-zA-Z0-9,\.\*\/\-]+\)/g);
> >               // set required
> >               var strReq = "0";
> >               //turn off red box - then turn on if error 
>below
> >               
>//elements[intLoop].parentNode.borderColor="lightblue";
> >               
>//elements[intLoop].parentNode.style.borderWidth="3px";
> >
> >               // Go through the edits for this field
> >
> > .....
> > ------------------------------------------
> >
> > This is the form section of the xsl file....
> >
> > </script>
> >
> >       <xsl:call-template name="header">
> >         <xsl:with-param name="ptitle"
> >         select="'Enterprise Registration Data Entry'" />
> >       </xsl:call-template>
> >
> >       <xsl:call-template name="script" />
> >
> > <!--<body OnLoad="placeFocus()">-->
> > <body onload="init()">
> >     <form name="mainform" METHOD="post"
> >             onSubmit="return doSubmit()"
> >
> > 
>ACTION="/promedica/servlet/promedica.AppDriver?opt=flow.GatherGuarInfo2">
> >
> >
> >
> >
> >           <xsl:call-template name="banner" />
> >
> >           <div id="tabs">
> >             <span id="tab1" class="tab">
> >             <font color="red">(X)</font>
> >
> >             Demographics</span>
> >
> >             <span id="tab2" class="tab">
> >             <font color="red">(X)</font>
> >             Next of Kin</span>
> >
> >             <span id="tab3" class="tab">
> >             <font color="red">(X)</font>
> >
> >             Visit</span>
> >
> >             <span id="tab4" class="tab">
> >             <font color="red">(X)</font>
> >
> >             Guarantor</span>
> >
> >             <span id="tab5" class="tab">
> >             <font color="red">(X)</font>
> >
> >             Insurance</span>
> >
> >             <input type="submit" name="save"
> >             value="Complete Registration" />
> >           </div>
> >
> >           <div id="content1" class="content">
> >             <table width="100" border="0" cellspacing="0"
> >             cellpadding="0">
> >               <xsl:apply-templates
> >               select="/Display/datamap/error" />
> >
> >
> >               <xsl:apply-templates
> >               select="/Display/Demographics" />
> >
> >             </table>
> >           </div>
> >
> >           <div id="content2" class="content">
> >             <table width="100" border="0" cellspacing="0"
> >             cellpadding="0">
> >               <xsl:apply-templates 
>select="/Display/Next_of_kin" />
> >             </table>
> >           </div>
> >
> >           <div id="content3" class="content">
> >             <table width="100" border="0" cellspacing="0"
> >             cellpadding="0">
> >               <xsl:apply-templates select="/Display/Visit" 
>/>
> >             </table>
> >           </div>
> >
> >           <div id="content4" class="content">
> >             <table width="550" border="0" cellspacing="0"
> >             cellpadding="0">
> >               <xsl:variable name="gtype"
> >               select="/Display/datamap/guarSelect" />
> >
> >               <xsl:choose>
> >                 <xsl:when test="$gtype='1'">
> >                   <xsl:apply-templates
> >                   select="/Display/GuarantorSelf" />
> >                 </xsl:when>
> >
> >                 <xsl:otherwise>
> >                   <xsl:apply-templates
> >                   select="/Display/Guarantor" />
> >                 </xsl:otherwise>
> >               </xsl:choose>
> >             </table>
> >           </div>
> >
> >           <div id="content5" class="content">
> >             <table width="550" border="0" cellspacing="0"
> >             cellpadding="0">
> > <!-- Content -->
> >               <xsl:variable name="itype"
> >               select="/Display/datamap/InsuranceType" />
> >
> >               <xsl:choose>
> >                 <xsl:when test="$itype='blue'">
> >                   <xsl:apply-templates
> >                   select="/Display/InsuranceBlue" />
> >                 </xsl:when>
> >
> >                 <xsl:when test="$itype='comm'">
> >                   <xsl:apply-templates
> >                   select="/Display/InsuranceComm" />
> >                 </xsl:when>
> >
> >                 <xsl:when test="$itype='care'">
> >                   <xsl:apply-templates
> >                   select="/Display/InsuranceCare" />
> >                 </xsl:when>
> >
> >                 <xsl:when test="$itype='self'">
> >                   <xsl:apply-templates
> >                   select="/Display/InsuranceSelf" />
> >                 </xsl:when>
> >
> >                 <xsl:otherwise>
> >                   <xsl:apply-templates
> >                   select="/Display/InsuranceHMO" />
> >                 </xsl:otherwise>
> >               </xsl:choose>
> >             </table>
> >           </div>
> >         </form>
> >
>
>
>
>  XSL-List info and archive:  
>http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]