Home > javascript > using typeof operator to gurantee the value of a variable

using typeof operator to gurantee the value of a variable

It checks whether a variable has been set.
I got it from somewhere else.

if (!(typeof worldHasEnded == “undefined”)) {
document.write(“YUP.”);
} else {
document.write(“NOPE.”);
}

dynamically adding element with html page

1.
2.
3. Dynamically add Textbox, Radio, Button in html Form using JavaScript
4.
5. function add(type) {
6.
7. //Create an input type dynamically.
8. var element = document.createElement(“input”);
9.
10. //Assign different attributes to the element.
11. element.setAttribute(“type”, type);
12. element.setAttribute(“value”, type);
13. element.setAttribute(“name”, type);
14.
15. var foo = document.getElementById(“fooBar”);
16.
17. //Append the element in page (in span).
18. foo.appendChild(element);
19.
20. }
21.
22.
23.
24.
25.

Dynamically add element in form.


26. Select the element and hit Add to add it in form.
27.

28.
29. Button
30. Textbox
31. Radio
32.
33.
34.
35.
36.  
37.
38.
39.
40.

original link:http://viralpatel.net/blogs/2009/01/dynamic-add-textbox-input-button-radio-element-html-javascript.html

Advertisements
Categories: javascript
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: