Jump to content

nurfnose

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

2 Neutral

About nurfnose

  • Rank
    Newbie
  1. Maybe I'm missing something, or not completely understanding... My processing page takes the user input to display the appropriate xml node on the fly. How can I store their input to bring it up later?
  2. I am trying to have a link submit some form data to a lightbox ( I am using facebox) and am having some trouble. The basic code I am working with is: <form name="form" method="post" action="test.asp"><ul><li><a href="#" onclick="document.forms['form'].dept.value = 'ACC'; document.forms['form'].course.value = '115'; document.form.submit('test.asp');" rel="facebox">ACC 115 Payroll Accounting</a></li></ul><input type="hidden" value="" name="dept" id="dept"><input type="hidden" value="" name="course" id="course"></form><script type="text/javascript">$('a[rel*=facebox]').facebox({ loading_image: '/images/loading.gif', close_image: '/images/closelabel.gif' });</script> This file submits to the test.asp file which processes the XML data which the course descriptions live. <%dim dept, coursedept = "ACC"course = "115"Set objxml = Server.CreateObject("Microsoft.XMLDOM")objxml.async = falseobjxml.load (Server.MapPath("classes.xml"))set ElemClass = objxml.getElementsByTagName("class[@dept='"&dept&"' and @class='"&course&"']")set ElemTitle = objxml.getElementsByTagName("class[@dept='"&dept&"' and @class='"&course&"']/title")set ElemDescription = objxml.getElementsByTagName("class[@dept='"&dept&"' and @class='"&course&"']/description")set ElemPrereqs = objxml.getElementsByTagName("class[@dept='"&dept&"' and @class='"&course&"']/prereqs")%><!DOCTYPE html><html><head><meta charset="utf-8"><title><% Response.Write(dept&" "&course) %></title></head><body><%For i=0 To (ElemClass.length -1)%><h3><% Response.Write(ElemTitle.item(i).Text) %></h3><p><% Response.Write(ElemDescription.item(i).Text) %></p><p><% Response.Write(ElemPrereqs.item(i).Text) %></p><%nextSet objxml = Nothing%></body></html> I have gotten everything to work, except I can't seem to get the form to put the test.asp in the lightbox. Help please!!
  3. I have an asp form where a user can select their campus and class section. I want to use their answers (variables) in the xsl file to pull only those options from the xml file. Anybody have an idea of how to make this work? Here is my xsl file: <?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table cellpadding="5" cellspacing="0" border="1"> <thead> <tr> <th>Class</th> <th>Type</th> <th>Day</th> <th>Time</th> <th>Tutor</th> <th>Location</th> </tr> </thead> <tbody> <xsl:for-each select="schedule/course[@section='<% response.write(section) %>' and @campus='<% response.write(campus) %>']"> <xsl:sort select="class" order="ascending"/> <tr> <td><xsl:value-of select="class"/></td> <td><xsl:value-of select="type"/></td> <td><xsl:value-of select="day"/></td> <td><xsl:value-of select="time"/></td> <td><xsl:value-of select="tutor"/></td> <td><xsl:value-of select="location"/></td> </tr> </xsl:for-each> </tbody> </table> </xsl:template></xsl:stylesheet> this is my asp file <%dim campus, sectioncampus = request.form("campus")section = request.form("section")'Load XMLset xml = Server.CreateObject("Microsoft.XMLDOM")xml.async = falsexml.load(Server.MapPath("tutor.xml"))'Load XSLset xsl = Server.CreateObject("Microsoft.XMLDOM")xsl.async = falsexsl.load(Server.MapPath("tutor.xsl"))'Transform fileResponse.Write(xml.transformNode(xsl))%>
  4. I want to edit xml from asp and xslt like the demo from w3schools. I am running into some snags.What I am trying to do is create a job list that has an approval function. I already have the form uploading to the xml document that allows users to submit their jobs. I am using xslt to be able to change the status of them from pending to approve. so the new xslt file will display for users all of the approved jobs.Here is my xml file <?xml version="1.0" encoding="utf-8"?><blast><job status='approve'> <position>developer</position> <posted>01/19/2012</posted> <company>JCC</company> <city>Jackson</city> <state>MI</state> <process>webaddress.com</process> <contact>da boss</contact></job><job status='pending'> <position>lunch lady</position> <posted>01/19/2012</posted> <company>high school</company> <city>lansing</city> <state>MI</state> <process>website.com</process> <contact>da boss lady</contact></job></blast> Here is my xslt file that displays the pending jobs for approval <?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"> <html> <head> </head> <body> <form method="post" action="editBlast.asp"> <h2>Job Approval</h2> <table cellpadding="5" cellspacing="0" border="1"> <tr> <th>Status</th> <th>Approval Action</th> <th>Position</th> <th>Company</th> <th>City</th> <th>State</th> <th>Contact</th> <th>Posted</th> </tr> <xsl:for-each select="blast/job[@status='pending']"> <tr> <td><xsl:value-of select="@status"/></td> <td> <input type="textbox" id="status" name="status" > <xsl:attribute name="value"> <xsl:value-of select="@status"/> </xsl:attribute> </input> Approve </td> <td><xsl:value-of select="position"/></td> <td><xsl:value-of select="company"/></td> <td><xsl:value-of select="city"/></td> <td><xsl:value-of select="state"/></td> <td><xsl:value-of select="contact"/></td> <td><xsl:value-of select="posted"/></td> </tr> </xsl:for-each> </table> <p><input type="submit" id="submit" name="submit" value="Submit"/> <input type="reset" id="reset" name="reset" value="Reset"/></p> </form> </body> </html></xsl:template></xsl:stylesheet> Here is my asp file: <%'-----------------------------------------------------------'The "loadXMLFile" Function accepts two parameters.'strXMLFile - The path and file name of the XML file.'strXSLFilee - The path and file name of the XSL file.'-----------------------------------------------------------Function loadXMLFile(strXMLFile, strXSLFile)'Declare local variablesDim objXMLDim objXSL 'Instantiate the XMLDOM Object that will hold the XML file.set objXML = Server.CreateObject("Microsoft.XMLDOM")'Turn off asyncronous file loading.objXML.async = false'Load the XML file.objXML.load(strXMLFile) 'Instantiate the XMLDOM Object that will hold the XSL file.set objXSL = Server.CreateObject("Microsoft.XMLDOM")'Turn off asyncronous file loading.objXSL.async = false'Load the XSL file.objXSL.load(strXSLFile) 'Use the "transformNode" method of the XMLDOM to apply the'XSL stylesheet to the XML document. Then the output is'written to the client.Response.Write(objXML.transformNode(objXSL))End Function '-----------------------------------------------------------'The "updateXML" Function accepts one parameter.'strXMLFile - The path and file name of the XML file.'-----------------------------------------------------------Function updateXML(strXMLFile)'Declare local variables.Dim objDomDim objRootDim objFieldDim x 'Instantiate the XMLDOM Object.set objDOM = Server.CreateObject("Microsoft.XMLDOM")'Turn off asyncronous file loading.objDOM.async = false'Load the XML file.objDOM.load strXMLFile 'Set the objRoot variable equal to the root element of the'XML file by calling the documentElement method of the'objDOM (XMLDOM) object.Set objRoot = objDom.documentElement 'Iterate through the Form Collection and write the'submitted values to the XML file.For x = 1 to Request.Form.Count 'Check see if "btn" is in the submitted value, if so, 'it is a button and should be ignored. If instr(1,Request.Form.Key(x),"btn") = 0 Then 'Set objField variable equal to a field_value element by 'calling the selectSingleNode method of the objRoot '(documentElement) object. The SelectSingleNode method 'accepts a string parameter for querying the XML document. 'In this case, the current value of the key property of 'the Form Collection is used to find the appropriate 'field_value element (more on this later). Set objField = objRoot.selectSingleNode("job[@status='" & _ Request.Form.Key(x) & "']") 'Set the text property of the objField (field_value) 'element equal to the value of the current form field. objField.Text = Request.Form(x) End IfNext 'After the XML file has been edited, is must be saved.objDom.save strXMLFile 'Release all of your object references.Set objDom = NothingSet objRoot = NothingSet objField = Nothing 'Call the loadXMLFile method, passing in the newly edited'XML file and the updatedcontact.xsl style sheet. This will'allow the client to see the edited information. More on the'updatedcontact.xsl file later.loadXMLFile strXMLFile,server.MapPath("blast_approved.xsl")End Function 'Test to see if the form has been submitted. If it has,'update the XML file. If not, transform the XML file for'editing.If Request.Form("btnSubmit") = "" Then loadXMLFile server.MapPath("../../forms-results/xml/text.xml"), _ server.MapPath("blast_pending.xsl")Else updateXML server.MapPath("../../forms-results/xml/text.xml")End If%> and finally my xslt file to display the approved jobs <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"> <html> <body><h2>Job Blast</h2> <table cellpadding="5" cellspacing="0" border="1"> <thead> <tr> <th>Position(s)</th> <th>Company</th> <th>City</th> <th>State</th> <th>Contact Information</th> <th>Posted</th> </tr> </thead> <tbody> <xsl:for-each select="blast/job[@status='approve']"> <xsl:sort select="posted" order="descending"/> <tr> <td><xsl:value-of select="position"/></td> <td><xsl:value-of select="company"/></td> <td><xsl:value-of select="city"/></td> <td><xsl:value-of select="state"/></td> <td><xsl:value-of select="contact"/></td> <td><xsl:value-of select="posted"/></td> </tr> </xsl:for-each> </tbody> </table> </body> </html></xsl:template></xsl:stylesheet> Thanks for your help!
×
×
  • Create New...