fellow programmers ![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
i'm humbly asking for your help (or at least another pair of eyes because i can't see the mistake!) i'm working with some drop-down lists and i'd like the other drop-down to show depending on the selected option from the first drop-down, and also i want it to contain options depending on the choice. here's the code:
<script language="javascript">
function show(elem) {
var tek=elem.options[elem.selectedIndex].value;
elem2=document.getElementById('contractId');
k=0;
shtml="<select>";
for(i=0; i<elem2.length;i++){
if (tek == elem2.options.value){
shtml += "<option>"+ elem2.options.text;
k++;
}
}
shtml="</select>";
if (k>0){
document.getElementById('divId').innerHTML=shtml;
document.getElementById('divId').style.visibility='visible'
}
else{
document.getElementById('divId').style.visibility='hidden'
}
}
</script>
divId is the id of the div where i placed the drop-down (it's in a <td>), contractId is the id of the second drop-down (it's hidden and consists of all available options for the drop-down);
so if the two integer values are equal i'm creating a new drop-down containing the specific options and placing it in the div
of course i'm triggering it with onchange="show(this)"
thanks in advance!! i appreciate it!!!![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
i'm humbly asking for your help (or at least another pair of eyes because i can't see the mistake!) i'm working with some drop-down lists and i'd like the other drop-down to show depending on the selected option from the first drop-down, and also i want it to contain options depending on the choice. here's the code:
<script language="javascript">
function show(elem) {
var tek=elem.options[elem.selectedIndex].value;
elem2=document.getElementById('contractId');
k=0;
shtml="<select>";
for(i=0; i<elem2.length;i++){
if (tek == elem2.options.value){
shtml += "<option>"+ elem2.options.text;
k++;
}
}
shtml="</select>";
if (k>0){
document.getElementById('divId').innerHTML=shtml;
document.getElementById('divId').style.visibility='visible'
}
else{
document.getElementById('divId').style.visibility='hidden'
}
}
</script>
divId is the id of the div where i placed the drop-down (it's in a <td>), contractId is the id of the second drop-down (it's hidden and consists of all available options for the drop-down);
so if the two integer values are equal i'm creating a new drop-down containing the specific options and placing it in the div
of course i'm triggering it with onchange="show(this)"
thanks in advance!! i appreciate it!!!