473,395 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to create Check Box and Select Tag

Hi there,

I'm new programmer in JavaScript. Can any one help in creating a
checkbox (by default selected) from JavaScript and creating Drop down
box (<select> ... </select>) from Javascript.

Thanks In Advance

Jul 20 '05 #1
1 44679
Raghuram Banda <ra************@nokia.sify.net> writes:
I'm new programmer in JavaScript. Can any one help in creating a
checkbox (by default selected) from JavaScript
var cb = document.createElement("input"); // create input node
cb.type = "checkbox"; // set type
cb.name = "checkboxName"; // set name if necessary
cb.checked = cb.defaultChecked = true; // make it checked now and by default

formRef.appendChild(cb); // add it to some form
and creating Drop down
box (<select> ... </select>) from Javascript.


var se = document.createElement("select");
cb.name = "selectName";
se.options[0] = new Option("selection 1","value 1");
se.options[1] = new Option("selection 2","value 2");
se.options[2] = new Option("selection 3","value 3");
se.options[3] = new Option("selection 4","value 4");

formRef.appendChild(se);

Hope this helps.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff McKeon | last post by:
I have a need to get data from the db that requires me to=20 1) do a select and create a new table with the results=20 2) run a query against that new table=20 3) drop the new table=20 I have...
1
by: Usman Ghani | last post by:
Hi All, Please help me to develop this one page please. I have a page on which I have a label control, just one label with no text. Next I start a loop to read the headers of emails and during...
0
by: phillip.s.powell | last post by:
CREATE TABLE /*! IF NOT EXISTS */ blah SELECT * FROM blah1 ON DUPLICATE KEY UPDATE unique_key=unique_key UNION SELECT * FROM blah2 ON DUPLICATE KEY UPDATE unique_key=unique_key TYPE=MyISAM ...
6
by: =?Utf-8?B?VG9kZCBKYXNwZXJz?= | last post by:
Hey guys, I really appreciate any advice you all can give me. I'm developing a ..NET 2.0 ASP page using VS 2005. This page will display "events". There is a MAIN event, and "sub" events. I...
1
by: tnguyen | last post by:
Hi all, Google search engine brought me here. I am so desperated and hope you guys could give me some help. This is my first .NET project to connect to AS400 database. I used...
2
by: shanmugamit | last post by:
hi, i want to create editable select box.but i have confuse to create editable select box.any one help me
1
by: akoymakoy | last post by:
Good Day I have these line of codes in my javascript ...... if (selObj.type == 'text' ) { parentObj = document.getElementById('destinationCity').parentNode; ...
1
by: Ashley Smith | last post by:
<form name='aForm'> Category: <select name='category'onchange="additems()"> <option value='None'>None selected yet <option value='Toy'>Toy <option value='City'>City <option...
3
by: Kylee Lothrop | last post by:
Hi, I was wondering if anyone knows how to create check boxes in a menu and have them toggle in VBA (Access 2003). Another option is to use a comboBox but I think this looks bad and a dropdown menu...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.