Subject: [xsl] Problems with form tag in javascript in an xml/xsl setup From: "Rochester, Dean" <Dean.Rochester@xxxxxxxxxxxxx> Date: Mon, 4 Mar 2002 14:45:53 -0500 |
Hi 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 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. 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. 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Combining HTML/FO StyleSh, Wendell Piez | Thread | Re: [xsl] Problems with form tag in, Thomas B. Passin |
Re: [xsl] Output: XML to XML scramb, Mike Ferrando | Date | Re: [xsl] Output: XML to XML scramb, Wendell Piez |
Month |