Could someone please please (before i tear my hair out
) tell me why the first code works but the second code errors with "object required" when there is only one line of code difference (for "start"), but the code is basically the same code that works for "name1"
Working
Not working
Below are the html of the page, and xml files referenced above
HTML
XML
cheers![[cheers] [cheers] [cheers]](/data/assets/smilies/cheers.gif)
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!
![[hairpull2] [hairpull2] [hairpull2]](/data/assets/smilies/hairpull2.gif)
Working
Code:
function testChoice(user){
$('progress').innerHTML = 'Processing request';
var url = 'data.xml';
var GroupID = $F('groupid');
var id = $F('id');
var pars = 'GroupID=' + GroupID + '&ID=' + id;
var req = new Ajax.Request('test.xml',{method:'get',onComplete:processResult});
}
function processResult(response){
try{
var val = response.responseXML;
//debugger;
var objName = val.getElementsByTagName('name');
var objDateStarted = val.getElementsByTagName('datestarted');
$('name1').value = objName.item(0).text;
$('progress').innerHTML = '';
alert("finished");
}//try
catch(e){
alert(e.message);
}
}
Not working
Code:
function testChoice(user){
$('progress').innerHTML = 'Processing request';
var url = 'data.xml';
var GroupID = $F('groupid');
var id = $F('id');
var pars = 'GroupID=' + GroupID + '&ID=' + id;
var req = new Ajax.Request('test.xml',{method:'get',onComplete:processResult});
}
function processResult(response){
try{
var val = response.responseXML;
//debugger;
var objName = val.getElementsByTagName('name');
var objDateStarted = val.getElementsByTagName('datestarted');
$('name1').value = objName.item(0).text;
//this line of code errors!!
$('start').value = objDateStarted.item(0).text;
$('progress').innerHTML = '';
alert("finished");
}//try
catch(e){
alert(e.message);
}
}
Below are the html of the page, and xml files referenced above
HTML
Code:
<body>
<form name="groupform" id="groupform" method="post" form action="[URL unfurl="true"]http://mydomain/cgi-bin/myapp.exe/savesubscription"[/URL]
onsubmit="return submitonce()">
<span id="progress"></span>
<input type="hidden" name="ID" value="29">
<input type="hidden" name="groupid" value="55">
<table bgcolor="#F4BAD8" width="100%">
<tr bgcolor="#F4BAD8">
<td colspan="2">
<h4>
Current Subscriptions</h4>
</td>
</tr>
<tr bgcolor="#F4BAD8">
<td>
Group
</td>
<td>
<select name="group" id="group" onchange="testChoice(29);">
<option value="-1">[SELECT]</option>
<option value="58">DFCoGroup</option>
<option value="60">FrankBobGroup</option>
<option value="68">SithTGroup</option>
<option value="70">CatalystGroup</option>
<option value="55">MadsoftGroup</option>
</select>
</td>
</tr>
</table>
</form>
<form action="[URL unfurl="true"]http://aphrodite/cgi-bin/osmos.exe/savesubscription"[/URL] name="addnew"
method="post" id="addnew">
<table class="post" bgcolor="#F4BAD8" width="100%">
<tr>
<td>
<input id="name1" name="name1" value=""><p/>
<input id="start" name="start" value=""><p/>
<input id="expires" name="expires" value=""><p/>
<input id="custom" name="custom" value=""><p/>
<input id="iscurrent" name="iscurrent" value=""><p/>
</td>
</tr>
<tr>
<td>
<input id="address" name="address" value="">
</td>
</tr>
</table>
</form>
</body>
XML
Code:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<data>
This is some sample data. It is stored in an XML file and retrieved by JavaScript.
</data>
<name>
Free
</name>
<datestarted>
25/10/2006 1:26:09 p.m.
</datestarted>
<dateexpires>
</dateexpires>
<custommonthlyrate>
</custommonthlyrate>
<iscurrent>
1
</iscurrent>
<address>
123 polar fleece lane
</address>
</root>
cheers
![[cheers] [cheers] [cheers]](/data/assets/smilies/cheers.gif)
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!