0

In this link, how to save types of car and types of phones in database with php?

I mean how to save Mercedes, Volvo, BMW, porche from car and Samsung, Nokia, Iphone from phone to database?

Below is my code :
html:

 <select id="cat">
        <option val="car">car</option>
        <option val="phone">phone</option>
    </select>

    <select id="item">

    </select>

script:

 cars=new Array("Mercedes","Volvo","BMW","porche");
phones=new Array('Samsung','Nokia','Iphone');

populateSelect();

$(function() {

      $('#cat').change(function(){
        populateSelect();
    });

});


function populateSelect(){
    cat=$('#cat').val();
    $('#item').html('');


    if(cat=='car'){
        cars.forEach(function(t) { 
            $('#item').append('<option>'+t+'</option>');
        });
    }

    if(cat=='phone'){
        phones.forEach(function(t) {
            $('#item').append('<option>'+t+'</option>');
        });
    }

} 
Bhushan Kawadkar
  • 28,279
  • 5
  • 35
  • 57
Neda
  • 57
  • 6

0 Answers0