Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Combo box

Quote Reply
Combo box
Hello

I made a relational database of cars, and put a javascript combobox to add the makers, the models and versions in only one form

It worked great to add, but when I whant to modify the record, I can´t get the defaults (related) of the record

I can use only the modelID but not the modelName

I can use the related <%models.modelName%> in the search results, but not in the modify form

Any ideas?

Fábio



Here´s the example of the javascript:

<SCRIPT LANGUAGE="JavaScript">

<!-- Início
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();
var arrItems2 = new Array();
var arrItemsGrp2 = new Array();

<!-- Opção 1 ACURA

arrItems1[12] = "LEGEND";
arrItemsGrp1[12] = 1;

arrItems1[13] = "LEGEND SEDAN";
arrItemsGrp1[13] = 1;
arrItems2[131] = "3.2 24v";
arrItemsGrp2[131] = 13
arrItems2[132] = "3.5 24v";
arrItemsGrp2[132] = 13

arrItems1[14] = "NSX";
arrItemsGrp1[14] = 1;
arrItems2[141] = "3.0";
arrItemsGrp2[141] = 14

<!-- Opção 2 ALFA ROMEU

arrItems1[22] = "145";
arrItemsGrp1[22] = 2;
arrItems2[221] = "Elegant 1.7 16V";
arrItemsGrp2[221] = 22
arrItems2[222] = "Elegant 1.8 16V";
arrItemsGrp2[222] = 22
arrItems2[223] = "Elegante 2.0 16V Twin Spark";
arrItemsGrp2[223] = 22
arrItems2[224] = "Quadrifoglio 2.0";
arrItemsGrp2[224] = 22
arrItems2[225] = "QV";
arrItemsGrp2[225] = 22

arrItems1[23] = "147";
arrItemsGrp1[23] = 2;
arrItems2[231] = "2.0 16V";
arrItemsGrp2[231] = 23
arrItems2[232] = "2.0 4p";
arrItemsGrp2[232] = 23

arrItems1[24] = "155";
arrItemsGrp1[24] = 2;
arrItems2[241] = "SPORT 2.0";
arrItemsGrp2[241] = 24
arrItems2[242] = "SUPER";
arrItemsGrp2[242] = 24


function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {
// Empty the third drop down box of any choices
for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null;
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "" ;
controlToPopulate.add(myEle) ;
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End -->

</script>




<SELECT id=firstChoice name=marca_veiculo onchange="selectChange(this, myform.secondChoice, arrItems1, arrItemsGrp1);">
<OPTION VALUE="1" <%if marca_veiculo == 1%>selected<%endif%>>ACURA</option>
<OPTION VALUE="2" <%if marca_veiculo == 2%>selected<%endif%>>ALFA ROMEO</option>
<OPTION VALUE="3" <%if marca_veiculo == 3%>selected<%endif%>>ASIA</option>
<OPTION VALUE="4" <%if marca_veiculo == 4%>selected<%endif%>>AUDI</option>
<OPTION VALUE="5" <%if marca_veiculo == 5%>selected<%endif%>>BMW</option>
<OPTION VALUE="6" <%if marca_veiculo == 6%>selected<%endif%>>CADILLAC</option>
<OPTION VALUE="7" <%if marca_veiculo == 7%>selected<%endif%>>CHAMONIX</option>
<OPTION VALUE="8" <%if marca_veiculo == 8%>selected<%endif%>>CHEVROLET</option>
<OPTION VALUE="9" <%if marca_veiculo == 9%>selected<%endif%>>CHRYSLER</option>
<OPTION VALUE="10" <%if marca_veiculo == 10%>selected<%endif%>>CITROEN</option>
<OPTION VALUE="11" <%if marca_veiculo == 11%>selected<%endif%>>DAEWOO</option>
<OPTION VALUE="12" <%if marca_veiculo == 12%>selected<%endif%>>DAIHATSU</option>
<OPTION VALUE="13" <%if marca_veiculo == 13%>selected<%endif%>>DODGE</option>
<OPTION VALUE="14" <%if marca_veiculo == 14%>selected<%endif%>>ENVEMO</option>
<OPTION VALUE="15" <%if marca_veiculo == 15%>selected<%endif%>>FERRARI</option>
<OPTION VALUE="16" <%if marca_veiculo == 16%>selected<%endif%>>FIAT</option>
<OPTION VALUE="17" <%if marca_veiculo == 17%>selected<%endif%>>FORD</option>
<OPTION VALUE="18" <%if marca_veiculo == 18%>selected<%endif%>>GURGEL</option>
<OPTION VALUE="19" <%if marca_veiculo == 19%>selected<%endif%>>HONDA</option>
<OPTION VALUE="20" <%if marca_veiculo == 20%>selected<%endif%>>HUMMER</option>
<OPTION VALUE="21" <%if marca_veiculo == 21%>selected<%endif%>>HYUNDAI</option>
<OPTION VALUE="22" <%if marca_veiculo == 22%>selected<%endif%>>ISUZU</option>
<OPTION VALUE="23" <%if marca_veiculo == 23%>selected<%endif%>>IVECO</option>
<OPTION VALUE="24" <%if marca_veiculo == 24%>selected<%endif%>>JAGUAR</option>
<OPTION VALUE="25" <%if marca_veiculo == 25%>selected<%endif%>>JEEP</option>
<OPTION VALUE="26" <%if marca_veiculo == 26%>selected<%endif%>>JPX</option>
<OPTION VALUE="27" <%if marca_veiculo == 27%>selected<%endif%>>KIA</option>
<OPTION VALUE="28" <%if marca_veiculo == 28%>selected<%endif%>>LADA</option>
<OPTION VALUE="29" <%if marca_veiculo == 29%>selected<%endif%>>LAND ROVER</option>
<OPTION VALUE="30" <%if marca_veiculo == 30%>selected<%endif%>>LEXUS</option>
<OPTION VALUE="31" <%if marca_veiculo == 31%>selected<%endif%>>MASERATI</option>
<OPTION VALUE="32" <%if marca_veiculo == 32%>selected<%endif%>>MAZDA</option>
<OPTION VALUE="33" <%if marca_veiculo == 33%>selected<%endif%>>MERCEDES-BENZ</option>
<OPTION VALUE="34" <%if marca_veiculo == 34%>selected<%endif%>>MITSUBISHI</option>
<OPTION VALUE="35" <%if marca_veiculo == 35%>selected<%endif%>>MP</option>
<OPTION VALUE="36" <%if marca_veiculo == 36%>selected<%endif%>>NISSAN</option>
<OPTION VALUE="37" <%if marca_veiculo == 37%>selected<%endif%>>OLDSMOBILE</option>
<OPTION VALUE="38" <%if marca_veiculo == 38%>selected<%endif%>>PEUGEOT</option>
<OPTION VALUE="39" <%if marca_veiculo == 39%>selected<%endif%>>PONTIAC</option>
<OPTION VALUE="40" <%if marca_veiculo == 40%>selected<%endif%>>PORSCHE</option>
<OPTION VALUE="41" <%if marca_veiculo == 41%>selected<%endif%>>PUMA</option>
<OPTION VALUE="42" <%if marca_veiculo == 42%>selected<%endif%>>RENAULT</option>
<OPTION VALUE="43" <%if marca_veiculo == 43%>selected<%endif%>>SAAB</option>
<OPTION VALUE="44" <%if marca_veiculo == 44%>selected<%endif%>>SANTA MATILDE</option>
<OPTION VALUE="45" <%if marca_veiculo == 45%>selected<%endif%>>SATURN</option>
<OPTION VALUE="46" <%if marca_veiculo == 46%>selected<%endif%>>SEAT</option>
<OPTION VALUE="47" <%if marca_veiculo == 47%>selected<%endif%>>SSANGYONG</option>
<OPTION VALUE="48" <%if marca_veiculo == 48%>selected<%endif%>>SUBARU</option>
<OPTION VALUE="49" <%if marca_veiculo == 49%>selected<%endif%>>SUZUKI</option>
<OPTION VALUE="50" <%if marca_veiculo == 50%>selected<%endif%>>TOYOTA</option>
<OPTION VALUE="51" <%if marca_veiculo == 51%>selected<%endif%>>TROLLER</option>
<OPTION VALUE="52" <%if marca_veiculo == 52%>selected<%endif%>>VOLKSWAGEN</option>
<OPTION VALUE="53" <%if marca_veiculo == 53%>selected<%endif%>>VOLVO</option>
<OPTION VALUE="54" <%if marca_veiculo == 54%>selected<%endif%>>WILLYS</option>
</select> <SELECT id=secondChoice name=modelo_veiculo onchange="selectChange(this, myform.thirdChoice, arrItems2, arrItemsGrp2);">
</SELECT> <SELECT id=thirdChoice name=versao_veiculo>
</SELECT>
Subject Author Views Date
Post Combo box assombracao 2563 Nov 13, 2002, 7:26 AM