Forum Moderators: open
<prefCenterOp>
<status>success</status>
<recordCount>1</recordCount>
</prefCenterOp>
I would like to change the image after it's clicked, depending on the value of <recordCount>1</recordCount>. It can either be "1" or "0"
So say I have image: 1a.jpg, when the user clicks it and XML returns recordcount 1, that image needs to change to 2a.jpg
How should I go about pulling this off?
Thanks!
You'd probably read the XML with JS [quirksmode.org], then switch on that.
I don't have any experience doing that, myself, simply because I always resolve XML to JSON [json.org] on the server, using PHP XML [us.php.net] or PHP XSLT [us.php.net], which is another possibility.
Actually, that XML is so simple you could probably use a JavaScript Regex to parse it. JS has good RegEx support [developer.mozilla.org].
but in this case? cmarshall is right, you'll be able to quickly grab that value by running the whole XML through a regex. once you have that little data element in a variable, you're one "if()" statement away from the solution