Jump to content

XForms to add data to an XML file


paulfrancis99

Recommended Posts

Why will the button not show on this xform page? (I just copied and pasted from W3C)I followed the xform tutorial on W3 schools (http://www.w3schools.com/xforms/xforms_example.asp) and copied the code and pasted it into my own site to see if it worked. This is the code i copied///////////////////////////////////////////////////////////<xforms><model> <instance> <person> <fname/> <lname/> </person> </instance> <submission id="form1" method="get" action="submit.asp"/></model><input ref="fname"><label>First Name</label></input><br /><input ref="lname"><label>Last Name</label></input><br /><br /><submit submission="form1"><label>Submit</label></submit></xforms>////////////////////////////////////////////////////////////////////////////////Then I load the page through a HTML page using JavaScript but it doesn't show the submit button. So obviously I can't submit anything. Any ideas why?If you need to see as well here is the HTML page/////////////////////////////////////////////////<html><head><style type="text/css"> .font1 { font-family: Tahoma,Verdana,Arial; font-size: 14px;} .font2 { font-family: Tahoma,Verdana,Arial; font-size: 18px; font-weight:bold}</style><script language="JScript"><!--function transformFiles(strStylesheetName) { // get a reference to the results DIV element var objResults = document.all['divResults']; // create two new document instances var objXML = new ActiveXObject('MSXML2.DOMDocument.3.0'); var objXSL = new ActiveXObject('MSXML2.DOMDocument.3.0'); // set the parser properties objXML.validateOnParse = true; objXSL.validateOnParse = true; // load the XML document and check for errors objXML.load('dating_database.xml'); if (objXML.parseError.errorCode != 0) { // error found so show error message and stop objResults.innerHTML = showError(objXML) return false; } // load the XSL stylesheet and check for errors objXSL.load(strStylesheetName); if (objXSL.parseError.errorCode != 0) { // error found so show error message and stop objResults.innerHTML = showError(objXSL) return false; } // all must be OK, so perform transformation strResult = objXML.transformNode(objXSL); // and display the results in the DIV element objResults.innerHTML = strResult; return true;}function showError(objDocument) { // create the error message var strError = new String; strError = 'Invalid XML file !<BR />' + 'File URL: ' + objDocument.parseError.url + '<BR />' + 'Line No.: ' + objDocument.parseError.line + '<BR />' + 'Character: ' + objDocument.parseError.linepos + '<BR />' + 'File Position: ' + objDocument.parseError.filepos + '<BR />' + 'Source Text: ' + objDocument.parseError.srcText + '<BR />' + 'Error Code: ' + objDocument.parseError.errorCode + '<BR />' + 'Description: ' + objDocument.parseError.reason return strError;}//--></script></head><body onLoad="transformFiles('ddb_clients.xsl')"><p><img src="logo.jpg" alt="logo"/><span class="font2">The Dating Database</span></p>View the tables as a   <button onClick="transformFiles('ddb_clients.xsl')">Catalog</button>  or as a   <button onClick="transformFiles('join.xml')">XForm</button><!-- to insert the results of the XSLT transformation --><div id="divResults"></div></body></html>/////////////////////////////////////////////////Most of the HTML file loads the results of a seperate xml file but when you click on the xform button (join.xml) it doesn't display the submit button. Any ideas why?ThanksPaul

Link to comment
Share on other sites

Before anything... the W3Schools tutorial is outdated, and not based on real world implementation.Try the XForms tutorial for HTML authors on W3C's site and keep in mind that only Firefox 2 + the XForms extension can display XForms. The add-on is not stable for FF3 yet.Also, keep in mind that to update an XML file, you don't have to use XForms. Nothing on the client side can actually (for security reasons). You need a server side scripting language to do the updating.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...