вопрос
Я использую это плагин https://github.com/corbosman/jquery-dynamic-selects
1. Вопрос
Хочу добавить новый select
Сделал так, но не работает:
добавил
В файле datasupplier.php
2. Вопрос:
Как можно задать цену в array states, county, towns, villages, ports
и вывести сумму selected options
1. Вопрос
Хочу добавить новый select
<select name="portID"><option value="">Choose Port</option></select>
Сделал так, но не работает:
<form>
<select name="stateID">
<option value="">Choose State</option>
<option value="MA">Massachusetts</option>
<option value="VT">Vermont</option>
</select>
<select name="countyID"><option value="">Choose County</option></select>
<select name="townID"><option value="">Choose Town</option></select>
<select name="villageID"><option value="">Choose Village</option></select>
</form>
$("form").relatedSelects({
onChangeLoad: 'datasupplier.php',
selects: ['stateID', 'countyID', 'townID', 'villageID']
});
добавил
<form>
<select name="stateID">
<option value="">Choose State</option>
<option value="MA">Massachusetts</option>
<option value="VT">Vermont</option>
</select>
<select name="countyID"><option value="">Choose County</option></select>
<select name="townID"><option value="">Choose Town</option></select>
<select name="villageID"><option value="">Choose Village</option></select>
<select name="portID"><option value="">Choose port</option></select>
</form>
$("form").relatedSelects({
onChangeLoad: 'datasupplier.php',
selects: ['stateID', 'countyID', 'townID', 'villageID', 'portID']
});
В файле datasupplier.php
sleep(1);
$stateID = $_GET['stateID'];
$countyID = $_GET['countyID'];
$townID = $_GET['townID'];
$villageID = $_GET['villageID']; ////////////////////////добавил
$html = $_GET['html'];
$states = array();
$states['MA'] = "Massachusetts";
$states['VT'] = "Vermont";
$states['SC'] = "South Carolina";
$counties = array();
$counties['MA']['BARN'] = 'Barnstable';
$counties['MA']['PLYM'] = 'Plymouth';
$counties['VT']['CHIT'] = 'Chittenden';
$counties['SC']['ANDE'] = 'Anderson';
$towns = array();
$towns['MA']['BARN']['CHA'] = "Chatham";
$towns['MA']['BARN']['DEN'] = "Dennis";
$towns['VT']['CHIT']['BUR'] = "Burlington";
$towns['VT']['CHIT']['ESS'] = "Essex";
$villages = array();
$villages['MA']['BARN']['CHA']['CCHA'] = 'Chatham';
$villages['MA']['BARN']['DEN']['DENP'] = 'Dennis Port';';
$villages['MA']['PLYM']['WAR']['WEWN'] = 'Weweantic';
$villages['VT']['CHIT']['BUR']['BURL'] = 'Burlington';
$port = array();////////////////////////добавил
$ports['MA']['BARN']['CHA']['CCHA']['PORT1'] = 'PORT 1';////////////////////////добавил
$ports['MA']['BARN']['DEN']['DENP']['PORT2'] = 'PORT 2';';////////////////////////добавил
$ports['MA']['PLYM']['WAR']['WEWN']['PORT3'] = 'PORT 3';////////////////////////добавил
$ports['VT']['CHIT']['BUR']['BURL']['PORT4'] = 'PORT 4';////////////////////////добавил
if($stateID && !$countyID && !$townID){
echo json_encode( $counties[$stateID] );
} elseif( $stateID && $countyID && !$townID ) {
echo json_encode( $towns[$stateID][$countyID] );
} elseif( isset($villages[$stateID][$countyID][$townID]) ) {
echo json_encode( $villages[$stateID][$countyID][$townID] );
} elseif( isset($ports[$stateID][$countyID][$townID][$villageID]) ) { ;////////////////////////добавил
echo json_encode( $ports[$stateID][$countyID][$townID][$villageID] );;////////////////////////добавил
} else {
echo '{}';
}
2. Вопрос:
Как можно задать цену в array states, county, towns, villages, ports
и вывести сумму selected options