使用javascript和xml进行变量赋值的语法

时间:2012-09-14 02:42:10

标签: javascript xml nodevalue

我尝试过这么多的作业变化,我累了,坏了 - 下面是xml和.js。我的目标是通过文本获取用户输入,并将该值分配给xml doc

中相应节点的值
<employee>
    <user>Michael McGraw</user>
    <password>password</password>
    <date></date>
    <in></in>
    <out></out>
</employee>

<script type="text/javascript">
if (window.XMLHttpRequest){
   xmlhttp=new XMLHttpRequest();
}
else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.open("POST","userPass.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

$(document).ready(function(){//when the page is ready. . . 

$('#datepicker').datepicker();//jquery ui datepicker, **this is the value Im working with
$('#timeIn').timepicker({ 'scrollDefaultNow': true });//jquery ui plug 
$('#timeOut').timepicker({ 'scrollDefaultNow': true });

$('#submit').on('click',function(event){//when user clicks submit do this. . . 
    var timeIn = (document.getElementById("timeIn").value);
    var timeOut = (document.getElementById("timeOut").value);
    var aDate = (document.getElementById("datepicker").value);
    xDate = xmlDoc.getElementsByTagName("date"); 
    xDate.nodeValue = aDate;////assign the value of datepicker=<date>
    alert(xDate.nodeValue);//please 

0 个答案:

没有答案