I have three dropdown lists having 6,3,3 options in them respectively. I need to compute a value depending on the combination of values chosen from the dropdown lists.I have 54 different values for 54 different permutations and combinations for the dropdown menus. Please suggest an optimized way of achieving this in php.
enter code here
<select name="designation" id="desg">
<option value="1">International Doctor</option>
<option value="2">Domestic Doctor</option>
<option value="3">MBBS STUDENT</option>
<option value="4">nursers </option>
<option value="5">Postgraduates / Interns</option>
<option value="6">Faculty</option>
</select>
<select name="workshop" id="wshop">
<option value="None">None</option>
<option value="workshop1">workshop1:PACET</option>
<option value="workshop2">workshop2:PEMC</option>
<option value="workshop3">workshop3:Research Workshop</option>
</select>
<select name="category" id="cat">
<option value="None">None</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
if a user select his designation,category,workshop the corresponding amount should be displayed picture contain a table with corresponding amount for different workshops,desginations,category
may be use like that
selectName[] selectName2[]
etc.
The Question is not very clear to me, but I am going to show an example which may help you.
This code may be similar to your code for this web page
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
var mapping={'13':'Bob','14':'Alice','23':'foo','24':'bar'}
function displayMapping(){
var e1=document.getElementById('l1')
var e2=document.getElementById('l2')
var key=e1.options[e1.selectedIndex].value+e2.options[e2.selectedIndex].value;
document.getElementById('sum').innerHTML =mapping[key];
}
</script>
</head>
<body>
<select name="l1" id='l1' onchange="displayMapping()">
<option value="1">1</option>
<option value="2">2</option>
</select>
<select name="l2" id='l2' onchange="displayMapping()">
<option value="3">3</option>
<option value="4">4</option>
</select>
<p name="sum" id='sum'></p>
</body>
</html>
You may create an assosiative array for your permutations (In this example array named mapping
), then you can create a function which will automatically called when there will any change in your dropdown lists (In this case that function is displayMapping()
).
This example uses javascript
hence reflected in local machine, If you want to calculate in server side then it may not be very useful to you.