Hi everybody,
I need some help and suggestions. I am trying to display all items of dropdown list where selected or unselected.
Is that possible in PHP or not?
If possible, help me to solve it. Or it is possible to display only selected items.
I have added items to dropdown list programmitically.
[COLOR=“Blue”]<HTML>
<HEAD>
<TITLE>untiled</TITLE>
<script>
//add selected size to dropdown
function AddSize()
{
// Create an Option object
var opt = document.createElement("option");
// Add an Option object to Drop Down/List Box
document.getElementById("ddlselected").options.add(opt);
// Assign text and value to Option object
var ddlist=window.document.getElementById('ddlsize');
var ddvalue=ddlist.options[ddlist.selectedIndex].value;
opt.text = ddvalue;
opt.value = ddvalue;
}
//add selected size to dropdown
function AddBinding()
{
// Create an Option object
var opt = document.createElement("option");
// Add an Option object to Drop Down/List Box
document.getElementById("ddlselectedbingdings").options.add(opt);
// Assign text and value to Option object
var ddlist=window.document.getElementById('ddlbindings');
var ddvalue=ddlist.options[ddlist.selectedIndex].value;
opt.text = ddvalue;
opt.value = ddvalue;
//opt.selected=true;
}
//remove selected item from dropdown
function removeOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i–)
{
if(selectbox.options[i].selected)
selectbox.remove(i);
}
}
</script>
</HEAD>
<BODY>
<form name=“isertp” id =“isertp” action=“” method=“post” enctype=“multipart/form-data”>
but in any case, when you put some options in the <select> and set multiple=“multiple” you must add to the name of the <select> so that an array of the selected values from the <select> will be sent to the php script.
Hi Kalon,
its not working, it will display only selected items. instead i want to display or get all items wheather selected or not.
If it is not possible, is there any way which will give same output.
when you submit a form, only the selected values will be sent.
if you want the values of all the options, whether selected or not, you could use javascript to get the values of all the options and store them in a hidden input in the form which will then be sent to the php script along with the other form data when the form is submitted.