0

我已经尝试了这么多的作业变体,我累坏了——下面是 xml 和 .js。我的目标是通过文本获取用户输入并将该值分配给 xml 文档中相应节点的值

<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 
4

0 回答 0