I have written a code as follow in the view.php
file for select,
<select name="bloodgroup" id="mem_religion">
<option value="">- Select Bloodgroup -</option>
<?php
foreach ($bloodgroups as $bloodgroup) { ?>
<option value="Option"> <?php echo $bloodgroup->bloodgroupname; ?>
<?php } ?>
</option>
</select>
which gives me the correct result. How can I get the selectedvalue in the controller.php
file?
You need to add form and button to post user selected value. Then in another page, retrieve the value. So:
In view.php:
<form method="post" action="/anotherpage">
<select name="bloodgroup" id="mem_religion">
<option value="">- Select Bloodgroup -</option>
<?php
foreach ($bloodgroups as $bloodgroup) { ?>
<option value="Option"> <?php echo $bloodgroup->bloodgroupname; ?>
<?php } ?>
</option>
</select>
<input type="submit" name="submit" value="submit">
</form>
In another page/controller:
$bloodgroup_selected = $this->input->post('bloodgroup');