javascript - Using HTML Input values in XML -
ok, i'm pretty much noob @ javascript, , totally have no thought xml, sorry if dumb question.
i have javascript file (created dymo, printer company) print browser label printer. can manually alter info gets printed. however, print whatever info provided html form input field, filled user.
the problem printed info comes xml within javascript.
what want know how can take info user types form, , place xml can print data. realize semi-broad question, , potentially difficult.
the form:
<form name="myform" onsubmit="return false"> qr info insertion: <input type="text" name="mytextfield" onchange="checkform()" autofocus> </form>
the javascript (pretty much unnecessary):
<script type="text/javascript" language="javascript"> function checkform() { var field1 = document.forms['myform'].elements['mytextfield'].value; alert(field1); } </script>
not sure exclusively helpful, below snippet of xml:
<styledtext>\ <element>\ <string>here want form info go</string>\ <attributes>\ <font family="arial" size="12" bold="false" italic="false" underline="false" strikeout="false" />\ <forecolor alpha="255" red="0" green="0" blue="0" />\ </attributes>\ </element>\ </styledtext>\
you can utilize dom manipulation in javascript function this:
// load xml document var xmldoc = loadxmldoc('yourxml.xml'); // find first string element var x = xmldoc.getelementsbytagname('string')[0]; // alter content of element x.textcontent = field1;
to load document can utilize approach http://www.w3schools.com/dom/dom_loadxmldoc.asp, not sure whether browsers back upwards that.
hope helps!
javascript html xml
No comments:
Post a Comment