Wednesday, May 29, 2024
 Popular · Latest · Hot · Upcoming
64
rated 0 times [  65] [ 1]  / answers: 1 / hits: 6348  / 11 Years ago, thu, january 9, 2014, 12:00:00

I am developing a stopwatch application in an attempt to learn the Dojo Toolkit. So, to start with, I need to set the hours, minutes, seconds and milliseconds to 0.



I tried:



dojo.byId(hours).value = 00;


Also tried:



domAttr.set(hours, 00);


It didnt work. In the console, the following error is thrown:



GET http://jobs.jsfiddle.net/random.js?callback=Request.JSONP.request_map.request_0 500 (Internal Server Error) moo-clientcide-1.3.js?jobofferinsidebar:3146


Here is my fiddle so far.



Please help!


More From » dojo

 Answers
4

That's because value is only used when working with form fields. If you want to replace the actual content of the DOM node, you use innerHTML or textContent in stead. For example:


dojo.byId("hours").innerHTML = "00";
dojo.byId("hours").textContent = "00";

or


domAttr.set("hours", "innerHTML", "00");
domAttr.set("hours", "textContent", "00");

The difference between innerHTML and textContent is that the latter only allows text content (like the property says), while innerHTML also allows to input HTML. If you don't trust the input, you should definitely be using textContent.


Be aware: you need to put quotes around the 00 because else it will be interpreted as a numeric value, which means the first 0 is skipped when you output it.


I also changed your JSFiddle.


[#48860] Wednesday, January 8, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ronniem

Total Points: 584
Total Questions: 111
Total Answers: 111

Location: Finland
Member since Sat, Nov 6, 2021
3 Years ago
;