I am using codeigniter-3 to develop web application i have one form which contains two dropdowns it's dependent each other.for example if i select any one in the first dropdown according to that the second dropdown data has to be rendered for that i wrote onchange function it's taking the value ,what i want is the myFunction() returning some data i want to print that data inside the html and php tag can you please help me to acheive this thing..?
This is example of how you can insert result from js function back to html
function myFunction() {
const e = document.getElementById("jobSel");
job = e.options[e.selectedIndex].value;
const node = document.createElement("p");
node.innerText = job;
document.getElementById("test").appendChild(node);
};
<div class="form-group">
<label for="exampleInputName1">Fuel Type</label>
<select name="f_type" id="jobSel" class="form-control" onchange="myFunction()">
<option value="">No Selected</option>
<option value="1">Petrol</option>
<option value="2">Diesel</option>
<option value="3">Kerosine</option>
<option value="4">Others</option>
</select>
</div>
<div id="test"></div>