my combo box id is combo1, i want to clear the values that are loaded in combo box from database, plz help me with sample code..
7 27548
my combo box id is combo1, i want to clear the values that are loaded in combo box from database, plz help me with sample code..
Post some code that we can help you with...
//my coding...
var strDetails;
var intLoop;
var strArrRow = new Array();
strDetails=xmlHttp.statusText;//records to load combo..
strArrRow =strDetails.split('|');
var x=document.getElementById("combo1");
for (intLoop=0;intLoop<strArrRow.length-1;intLoop++)
{
var y=document.createElement('option');
y.text=strArrRow[intLoop]
try
{
x.add(y, null);
}
catch(ex)
{
x.add(y);
}
}
//my coding...
var strDetails;
var intLoop;
var strArrRow = new Array();
strDetails=xmlHttp.statusText;//records to load combo..
strArrRow =strDetails.split('|');
var x=document.getElementById("combo1");
for (intLoop=0;intLoop<strArrRow.length-1;intLoop++)
{
var y=document.createElement('option');
y.text=strArrRow[intLoop]
try
{
x.add(y, null);
}
catch(ex)
{
x.add(y);
}
}
I'm a bit confused here. Do you want to delete values from the database or do you want to clear options from a select box?
sorry to make u confused sir, i want to clear the options from the select box. not from database.
sorry to make u confused sir, i want to clear the options from the select box. not from database.
Well the general rule is if you have a select by the name box, then
To clear all options of box just do
box.options.length = 0;
Well the general rule is if you have a select by the name box, then
To clear all options of box just do
box.options.length = 0;
This is by far the best way to remove the options. If you try to remove them one by one in a loop you won't be able to remove the last option. I lost a good bit of hair before realizing that options.length=0; is all I needed :/
This is by far the best way to remove the options. If you try to remove them one by one in a loop you won't be able to remove the last option. I lost a good bit of hair before realizing that options.length=0; is all I needed :/
I hope the hair grew back on.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mr_burns |
last post by:
hi,
using javascript, how do i select an option in a combo box? i have
tried looking on the internet but dont really know what i should be
searching for. what i want to happen is that when a...
|
by: Stephen Miller |
last post by:
I have a page with many, dynamically generated combo boxes and I want
to check all of them, before I add a unique value to specific combo.
What would be the best way to work through the document...
|
by: SAN CAZIANO |
last post by:
how can clear an html SELECT and next insert in it all the elements of an array ()
I try this but seems doesn't works.
function ComboAddArrayValueWithLabel(combo,ArrayLabel,ArrayValue)
{ ...
|
by: Harry Haller |
last post by:
<select name="cboPlaces" id="cboPlaces">
<option value="3">Countryside</option>
<option value="4">Forest</option>
<option value="5">Mountain</option>
<option value="6">Desert</option>
<option...
|
by: Eric Layman |
last post by:
Hi,
I have a radio button and a combo box.
Upon changing a value for radio button, the combo box values will be
dynamically updated.
I have an idea on how to go abt doing it but Im stuck...
|
by: buss123 |
last post by:
Hi all,
combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |