anmldr
unread,Jan 18, 2009, 11:57:34 PM1/18/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to iPhoneWebDev
I am using the toggle button from iUI. I need to add to a way to find
out if the value is "Yes" vs "No" or "True" vs "False". In my case, I
am using "Pounds" vs "Kilograms" (or lbs vs kgs) before I perform a
calculation. I do NOT know js and so would appreciate some help. What
would I add in the HTML and/or js to be able to see which is selected?
The js for this is:
(function() {
addEventListener("click", function(event)
{
var div = findParent(event.target, "div");
if (div && hasClass(div, "toggle"))
{
div.setAttribute("toggled", div.getAttribute("toggled") !=
"true");
event.preventDefault();
}
}, true);
function findParent(node, localName)
{
while (node && (node.nodeType != 1 || node.localName.toLowerCase
() != localName))
node = node.parentNode;
return node;
}
function hasClass(self, name)
{
var re = new RegExp("(^|\\s)"+name+"($|\\s)");
return re.exec(self.getAttribute("class")) != null;
}
})();
Linda