[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: ANNOUNCE: New release of X-Tract

  • From: "Paul R. Brown" <prb@u...>
  • To: "ashutosh dandavate" <ald_blk@h...>
  • Date: Tue, 29 Feb 2000 20:11:47 -0600

toform.submit

Hi, Ashutosh --

You don't need XMLScript or anything special do what you're asking...  Just
write some Javscript functions; here's an example to get you started.  The
code below uses an invisible form as a container to XML-ify the elements of
another form.  To use it, set the "submit" method of your form to the
submitXMLdata() function...

<SCRIPT language="Javascript">
function o_tag(objElement,strTag) {
  objElement.value += "<" + strTag + ">";
}

function c_tag(objElement,strTag) {
  o_tag(objElement,"/"+strTag);
}

function submitXMLdata(formFrom,formTo) {
  var objElement = window.document.forms[formTo].elements[0];
  // put your XML declaration below
  objElement.value = "";
  // write the document element
  o_tag(objElement,"formdata");
  // loop through the form elements
  for (var i=0;i<window.document.forms[formForm].elements.length;i++) {
    var objFoo = window.document.forms[formForm].elements[i];
    o_tag(objFoo.name);
    switch (objFoo) {
      case "text":
        objElement.value += objFoo.value;
        break;
      case "select-one":
        objElement.value += objFoo.options[objFoo.selectedIndex].value;
        break;
      // And you can write some routines here to
      // loop over the selected indices in a
      // multi-select, or to handle checkbox values,
      // or...
    }
    c_tag(objElement,objFoo.name);
  }
  // close the document element
  c_tag(objElement,"formdata");
  // send it on its way
  toForm.submit();
}
</SCRIPT>

<form name="unseen" action="targeturl.cgi" method="POST">
	<input type="HIDDEN" name="XMLdata">
</form>

Or, depeding on your exact needs, you can do a myriad of other things.
Unless you need some real firepower on the client-side, there is no reason
to use anything other than Javascript.  The only reason to use Javascript is
that the client can perform operations that would otherwise burden the
server (if you have a lot of traffic or get a denial of service attack...).
(In this case, you're going to be parsing a form submission either way,
whether it's a straight form or XML wrapped in a form, so I don't see the
benefits of XML-i-fying the data on the client.)

	- Paul


***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/threads.html
***************************************************************************

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.