Set Value for HTML Dropdown based on Another HTML Dropdown Selection - javascript

I have an HTML dropdown list, that when a value is selected, it displays a table that corresponds to the selection. I also have an Add Button. Inside the Add Button are 2 fields of information that need filled out, one being a dropdown box. Here is what I need but cannot figure out. I want the selected value on the dropdown in my Add Button to be the number that was already selected in the first dropdown. How can I do this?
Here is the code that I have so far:
<button class="ui-button ui-corner-all ui-widget" id="insertButton">Add Supplier ID</button><br><br>
<div id="dialog-form" title="Add Supplier ID">
<p class="validateTips">All form fields are required.</p>
<!-- Dialog box displayed after add row button is clicked -->
<form>
<fieldset>
<label for="mr_name">MR_ID</label>
<select name="mr_id" id="mr_id_dialog" class="text ui-widget-content ui-corner-all" value="300">
<?php foreach($user->fetchAll() as $user1) { ?>
<option>
<?php echo $user1['MR_ID'];?>
</option>
<?php } ?>
</select><br><br>
<label for="buyer_id">Supplier ID</label>
<input type="text" name="supp_id" id="supplier_id" class="text ui-widget-content ui-corner-all" value="99">
<!-- Allow form submission with keyboard without duplicating the dialog button -->
<input type="submit" id="submit" tabindex="-1" style="position:absolute; top:-1000px">
</fieldset>
</form>
</div>
<!-- Form -->
<form name="myForm" action="">
<!-- Dropdown List -->
<select name="master_dropdown" id="mr_id" onChange="updatetable(this.form);">
<option selected value="select">Choose a MR_ID</option>
<?php foreach($users->fetchAll() as $user) { ?>
<option data-name="<?php echo $user['MR_ID'];?>">
<?php echo $user['MR_ID'];?>
</option>
<?php } ?>
</select>
</form>
<!-- Table -->
<p>
<div id="table_div">
<table border="1" id="index_table" class="ui-widget ui-widget-content" style="display: none">
<thead>
<tr class="ui-widget-header">
<td>MR ID</td>
<td>Supplier ID</td>
</tr>
</thead>
<?php foreach($users_one->fetchAll() as $supp) { ?>
<tr>
<td class="mr_id"><div id="dropdown_selection"></div></td>
<td class="supp_id"><?php echo $supp['Supp_ID']?></td>
</tr>
<?php } ?>
</table>
</div>

See Events for Select for info on events with Select tag
This can be done with javascript.
Add a change listener to the first dropdown and remove the onChange from the HTML. You can call the updatetable function from within the javascript.
javascript
function bindListeners() {
var elementToBind = document.querySelector('#mr_id');
// Check if the element has loaded
if(elementToBind === undefined) {
// if not, wait 500ms and retry
setTimeout(bindListeners, 500);
}
else
{
// Add the event listeners
elementToBind.addEventListener('change', updateSelection, false);
elementToBind.addEventListener('click', updateSelection, false);
}
}
bindListeners();
function updateSelection(event) {
// Get the value from this select
var selectedValue = event.target.value;
// find the select object that you want to set the value for
var selectObjectToSet = document.querySelector('#mr_id_dialog');
selectObjectToSet.value = selectedValue;
// Call the function that was in the onChange listener
updatetable(this.form);
}
HTML
Add Supplier ID
<div id="dialog-form" title="Add Supplier ID">
<p class="validateTips">All form fields are required.</p>
<!-- Dialog box displayed after add row button is clicked -->
<form>
<fieldset>
<label for="mr_name">MR_ID</label>
<select name="mr_id" id="mr_id_dialog" class="text ui-widget-content ui-corner-all" value="300">
<?php foreach($user->fetchAll() as $user1) { ?>
<option>
<?php echo $user1['MR_ID'];?>
</option>
<?php } ?>
</select><br><br>
<label for="buyer_id">Supplier ID</label>
<input type="text" name="supp_id" id="supplier_id" class="text ui-widget-content ui-corner-all" value="99">
<!-- Allow form submission with keyboard without duplicating the dialog button -->
<input type="submit" id="submit" tabindex="-1" style="position:absolute; top:-1000px">
</fieldset>
</form>
</div>
<!-- Form -->
<form name="myForm" action="">
<!-- Dropdown List -->
<select name="master_dropdown" id="mr_id" onChange="updatetable(this.form);">
<option selected value="select">Choose a MR_ID</option>
<?php foreach($users->fetchAll() as $user) { ?>
<option data-name="<?php echo $user['MR_ID'];?>">
<?php echo $user['MR_ID'];?>
</option>
<?php } ?>
</select>
</form>
<!-- Table -->
<p>
<div id="table_div">
<table border="1" id="index_table" class="ui-widget ui-widget-content" style="display: none">
<thead>
<tr class="ui-widget-header">
<td>MR ID</td>
<td>Supplier ID</td>
</tr>
</thead>
<?php foreach($users_one->fetchAll() as $supp) { ?>
<tr>
<td class="mr_id"><div id="dropdown_selection"></div></td>
<td class="supp_id"><?php echo $supp['Supp_ID']?></td>
</tr>
<?php } ?>
</table>
</div>
</p>

Related

Get data-price attribute from dynamically added row and put inside the input box

how to get data-price inside the text box using select in php html and sql?
i tried this so far. what im trying to do is, when i change the selection box, the input box beside should change base on the value of data-price.
been trying this for a week.
e.g
select debit
local treasury 100
<script>
$(document).ready(function(){
var i=1;
var chart_add = '<tr id="row_chart'+i+'"><td><select name="chart_of_account[]" class="selectpicker" data-live-search="true"><option style="width: 400px;">--Select Chart of Account--</option><?php $chart=mysqli_query($conn,"Select acoount_no,account_title from chart_of_account"); while($row=mysqli_fetch_assoc($chart)){$account_no = $row["acoount_no"]; $account_title = $row["account_title"];?><option value="<?php echo $account_no; ?>" style="width: 400px;"><?php echo $account_no ." | ". $account_title; ?></option><?php }?></select></td><td><input type="text" name="chart_debit[]" class="form-control chart_debit" id="chart_debit"onchange="chart_change_debit()"></td><td><input type="text" name="chart_credit[]" class="form-control chart_credit" id="chart_credit" onchange="chart_change_credit()"></td><td><button type="button" name="remove_chart" id="'+i+'" class="btn btn-danger remove_chart">X</button></td></tr>';
$('#add').click(function(){
i++;
$('#dynamic_field').append(chart_add);
$('.selectpicker').selectpicker('render');
$('.chart_debit').val($('select[name="chart_of_account"] option:selected').data('price'));
});
$(document).on('click', '.remove_chart', function(){
var button_id = $(this).attr("id");
$('#row_chart'+button_id+'').remove();
});
});
</script>
<form method = "POST" name="add_name" id="add_name">
<div class="row">
<div class="col-md-12">
<!-- chart of account -->
<div class="row">
<div class="col-md-12">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Chart of Account</h3>
</div>
<div class="box-body">
<table class="table table-bordered" id="dynamic_field">
<tr>
<th rowspan="2">Chart of Account</th>
<th>Debit</th>
<th>Credit</th>
<th rowspan="2"><button type="button" name="add" id="add" class="btn btn-success">Add More</button></th>
</tr>
<tr>
<th>
<input type="text" name="chart_debit_sum" class="form-control chart_debit_sum" id="chart_debit_sum" readonly>
</th>
<th>
<input type="text" name="chart_credit_sum" class="form-control chart_credit_sum" id="chart_credit_sum" readonly>
</th>
</tr>
<tr>
<td>
<select name="chart_of_account[]" class="selectpicker" data-live-search="true">
<option style="width: 400px;">--Select Chart of Account--</option>
<?php
$chart = mysqli_query($conn,"Select acoount_no,account_title from chart_of_account");
while($row = mysqli_fetch_assoc($chart)){
$account_no = $row['acoount_no'];
$account_title = $row['account_title'];
$amount = $row['test_amount'];
?>
<option value = "<?php echo $account_no; ?>" style="width: 400px;" data-price = "<?php echo $amount; ?>">
<?php echo $account_no . " | " .$account_title; ?>
</option>
<?php } ?>
</select>
</td>
<td>
<input type="text" name="chart_debit[]" class="form-control chart_debit" id="chart_debit" onchange="chart_change_debit()">
</td>
<td>
<input type="text" name="chart_credit[]" class="form-control chart_credit" id="chart_credit" onchange="chart_change_credit()">
</td>
<td></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<!-- chart of account -->
</div>
<!-- chart and sub-->
</div>
</form>
sample screenshot

How to display the list from database using selected value in drop down

manage_bank
Hi everyone,
Can someone help me, How to display the bank name based on selected drop down, when we choose
for example:- 50 records
then it will display 50 records of the bank name from database.
When we logout the value still remain the same 50 records.
<?php
// Includes the required files
include ("../ecompany/terms_includes.php");
?>
<?php
// Check user authority for this page
$ModuleName = "Manage Banks";
$ModuleAction = "view";
base_checkAuthority($ModuleName,$ModuleAction)
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include PATH_INC_HEAD;
?>
<?php
//get page number
$page = $_GET["page"];
$record = $_GET["record"];
//get Miscellaneous detail
$MiscellaneousDetail = base_getMiscellaneousDetail();
?>
<?php
if(!isset($page))
{
$page = 1;
}
if(!isset($record))
{
$record = $MiscellaneousDetail['base_mis_default'];
}
//go to reload page
if(isset($_POST['load']))
{
$page = 1;
$record = $_POST['records_per_page'];
}
//go to add profile page
if(isset($_POST['add']))
{
echo '<script type="text/javascript">' . "\n";
echo 'window.location="../ecompany/add_bank.php";';
echo '</script>';
}
//go to home page
if(isset($_POST['cancel']))
{
echo '<script type="text/javascript">' . "\n";
echo 'window.location="../terms_base/home.php";';
echo '</script>';
}
?>
</head>
<body>
<div class="container">
<?php
include PATH_INC_HEADER;
?>
<div class="main_body1">
<div id="update_category"></div>
<div style="width:800px; margin:auto">
<?php
include PATH_INC_DESC;
?>
<div style="clear:both"></div>
<form name="bank_list_form" id="bank_list_form" method="post" action="">
<div style="width:800px; margin:auto; text-align:left">
<select name="records_per_page" id="records_per_page" >
<option value="<?php echo $record; ?>">Default Records/Page :</option>
<option value="1" title="1" >1</option>
<option value="3" title="3" >3</option>
<option value="5" title="5" >5</option>
<option value="10" title="10" >10</option>
<option value="20" title="20" >20</option>
<option value="30" title="30" >30</option>
<option value="50" title="50" >50</option>
<option value="100" title="100" >100</option>
<option value="200" title="200" >200</option>
<option value="500" title="500" >500</option>
<option value="1000" title="1000" >1000</option>
</select>
<input type="" size="4" style="width:25px" name="record"
id="record"value="<?php echo $record; ?>" readonly="readonly" />
<div id="searchbutton">
<input type="submit" id="load" name="load" value="Refresh">
</div>
</div>
<table cellspacing="1" class="tablesorter">
<thead>
<tr>
<th></th>
<th>Code</th>
<th>Name</th>
<th>Description</th>
<th>Remark</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php ecoy_listBank($page, $record) ?>
</tbody>
<tr>
<td align="center" colspan="8"><input type="submit" id="add"
name="add" value="Add Bank" /><input type="submit" id="cancel"
name="cancel" value="Cancel" /></td>
</tr>
</tfoot>
</table>
</form>
<br />
</div>
<div class="clearboth"></div>
</div>
<?php
include PATH_INC_FOOTER;
?>
</div>
</body>
</html>
Much appreciate, Thanks.
The title of your question is misleading. But if I got it right you actually succeed in querying your data correctly and refreshing the number of records with your refresh button.
You real question is how to persist the default value of the dropdown after a logout.
By mentioning your logout feature I assume you have users and a user table in your database.
From here you have two solutions I can think of:
1. Save the users preferences like the default value of your dropdown within your users table or create a separated table dedicated for this purpose.
2. Store users preferences in cookies

Goes back to modal after pressing submit

Hey guys I'm currently having problems with my Modal. As I register a member, it doesn't go back to the modal after successfully registering it. I believe it has something to do with scripts. Here's the code:
Add Member
<!-- Add Member Modal -->
<div id="addMemberModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add Member</h4>
</div>
<div class="modal-body">
<div class="col-md-6 col-sm-6 no-padng">
<div class="model-l">
<form name="registration" method="post">
<table border="0" width="500" align="center" class="demo-table">
<div class="message"><?php if(isset($message)) echo $message; ?></div>
<tr>
<td><p class="textColor">First Name:</p></td>
<td><input type="text" class="demoInputBox" name="firstName" placeholder="First Name" value="<?php if(isset($_POST['firstName'])) echo $_POST['firstName']; ?>"; required></td>
</tr>
<tr>
<td><p class="textColor">Family Name:</td>
<td><input type="text" class="demoInputBox" name="lastName" placeholder="Family Name" value="<?php if(isset($_POST['lastName'])) echo $_POST['lastName']; ?>"; required></td>
</tr>
<tr>
<td><p class="textColor">Contact</td>
<td><input type="text" class="demoInputBox" name="contact" placeholder="Contact No." value="<?php if(isset($_POST['contact'])) echo $_POST['contact']; ?>"; required></td>
</tr>
<tr>
<td><p class="textColor">Email</td>
<td><input type="text" class="demoInputBox" name="email" placeholder="Email" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>"; required></td>
</tr>
<tr>
<td><p class="textColor">Gender</td>
<td><input type="radio" name="gender" value="M" <?php if(isset($_POST['gender']) && $_POST['gender']=="Male") { ?>checked<?php } ?>><p class="textColor"; required>Male</p>
<br><input type="radio" name="gender" value="F" <?php if(isset($_POST['gender']) && $_POST['gender']=="Female") { ?>checked<?php } ?>><p class="textColor"; required>Female
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
<div>
<input type="submit" name="submit" value="Add Member" class="btnRegister">
</div>
</form>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I'm open to receiving answers and learning lessons from you guys as well because Boostrap Modal isn't being taught in our school. I'll be very happy if somebody will help me with this. Thank you so much! :)
First thing:
I really don't understand why you have used value="<?php echo $_POST['value']?>" with every input type what it does is, it fills form input with the submitted data. If you remove this value="<?php echo $_POST["firstName"] ?>" from every input type, you will only need to trigger the modal using the following code.
<script type="text/javascript">
$(document).ready(function(){
//check whether user form submitted
var test ="<?php echo $_POST["submit"] ?>";
//check if form is submmited
if(test){
$("#addMemberModal").modal("show");
}
});
</script>
If You still don't want to remove value="<?php echo $_POST['value']?>".Then try the following:
<script type="text/javascript">
$(document).ready(function(){
//check whether user form submitted
var test ="<?php echo $_POST["submit"] ?>";
// function for clearing input
$.clearInput = function (modal) {
$(modal).find('input[type=text], input[type=radio]').val("");
};
//check if form is submmited
if(test){
// //show the modal
$("#addMemberModal").modal("show");
//on modal show clear the inputs
$("#addMemberModal").on("shown.bs.modal",function(){
$.clearInput(this);
});
}
});
</script>
For any of the above case to work you also need to include Jquery in head section:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
NOTE: Above code should work as per your requirement but this is not a recommended method. If you want to add new member information again and again, you should submit the data via JQuery or Ajax post and on successful submission should reset the form, instead of reloading the entire page.

Search Html Table and Display Results Without Refresh

I have a group of fields above my table and these fields are used to search my table. Here's a code snippet:
<?php $form = ActiveForm::begin(['id' => 'devicemgmt-form']); ?>
<div class="container-fluid">
<div class="row">
<div class="col-sm-5">
<div class="row">
<div class="col-sm-5">Device Name</div>
<div class="col-sm-7">
<input type="text" name="device-name" class="form-control input-sm">
</div>
</div>
<br>
<div class="row">
<div class="col-sm-5">Broadcasted Program</div>
<div class="col-sm-7">
<select name="country" class="form-control input-sm">
<option selected disabled>Please Select</option>
<?php
foreach($devices as $key => $value):
echo '<option value="'.$key.'">'.$value['Broadcasted Program'].'</option>';
endforeach;
?>
</select>
</div>
</div>
<br>
<div class="row">
<div class="col-sm-5">Store</div>
<div class="col-sm-7">
<select class="form-control input-sm">
<option selected disabled>Please Select</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
</div>
</div>
<div class="col-sm-5">
<div class="row">
<div class="col-sm-5">Model name</div>
<div class="col-sm-7">
<select name="country" class="form-control input-sm">
<option selected disabled>Please Select</option>
<?php
foreach($devices as $key => $value):
echo '<option value="'.$key.'">'.$value['Device Model'].'</option>';
endforeach;
?>
</select>
</div>
</div>
<br>
<div class="row">
<div class="col-sm-5">Status</div>
<div class="col-sm-7">
<select class="form-control input-sm">
<option selected disabled>Please Select</option>
<option>Started</option>
<option>Pending</option>
<option>Complete</option>
</select>
</div>
</div>
<br>
<div class="row">
<div class="col-sm-5">Log Output Date</div>
<div class="col-sm-7">
<input type="text" name="device-name" class="form-control input-sm">
</div>
</div>
</div>
<div class="col-sm-2">
<div class="row" style="height: 98px;"></div>
<div class="row">
<button href="#" class="btn download-btn" id="downloadBtn">Log Download</button>
</div>
</div>
</div>
</div>
<?php ActiveForm::end(); ?>
<div class="container-fluid">
<table id="device-list_table" class="table table-striped table-bordered dataTable display">
<thead>
<tr>
<th class="text-center"><input type="checkbox" id="selectAll"></th>
<th class="text-center">Device Name</th>
<th class="text-center">Device Model</th>
<th class="text-center">Broadcasted Program</th>
<th class="text-center" colspan="2">Device Status</th>
<th class="text-center">Last Communication Date and Time</th>
<th class="text-center"></th>
</tr>
</thead>
<tbody>
<?php foreach($devices as $key => $value) { ?>
<tr>
<td class="text-center"><input type="checkbox" name="device-checkbox" value="<?= $value['Device Name'] ?>" id="<?php echo 'boxId'.$key ?>"></td>
<td class="text-center"><?= $value['Device Name']; ?></td>
<td class="text-center"><?= $value['Device Model']; ?></td>
<td class="text-center"><?= $value['Broadcasted Program']; ?></td>
<td class="text-center">
<?php
if ($value['Device Status'] == "Start") {
echo "<font color='yellow'>⚫</font>";
} elseif ($value['Device Status'] == "Pending") {
echo "<font color='red'>⚫</font>";
} elseif ($value['Device Status'] == "Complete") {
echo "<font color='green'>⚫</font>";
}
?>
</td>
<td class="text-center"><?= $value['Device Status']; ?></td>
<td class="text-center"><?= $value['Last Communication Date and Time']; ?></td>
<td class="text-center">
<ul class="list-inline">
<li>
<button href="#" class="btn">
Display Log
</button>
</li>
<li>
<button href="#" class="btn">
Edit
</button>
</li>
</ul>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
How do I search data in my table and display the results (inside the same table) without refreshing the page? As you can see, I have a "Log Download" button, maybe when I click that, the results will then show.
EDIT:
Somewhat like the implementation of dataTables (https://www.datatables.net/) but in my case, I have multiple form fields to use in searching.
You can do like
$("#deviceName").keyup(function(){
var filter = $(this).val();
$("#device-list_table tr td").each(function(){
if ($(this).text().search(new RegExp(filter, "i")) < 0) {
$(this).hide();
} else {
$(this).show();
}
});
});
This is only for deviceName type you can add other properties also
here is a simple Jquery plugin for that
http://www.jqueryscript.net/table/Simple-jQuery-Plugin-For-Html-Table-Live-Search.html
Include the jQuery library and the jQuery Html Table Search plugin in the web page.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="html-table-search.js"></script>
Call the plugin on an existing Html table.
$(document).ready(function(){
$('table.search-table').tableSearch();
});
I am not quite sure what you are asking, but if I understand you correctly, you have a <table> element that contains searchable information, and you would like this table to update to contain only the search results after users use the search function?
In this case, you can do this through AJAX requests in the following manner. Create a .php file that generates the contents of the table based on the input from your search function (let us call it generateTable.php), sent to it through the $_GET variable. generateTable.php goes something like this:
$result = search($_GET['device-name'], $_GET['country'], $_GET['store']...);
echo '<tr><td>' . $result[0] . '</td><td>' . $result[1] . '</td><td>' . $result[2] . '</td><td>'...'</tr>'
Where search() is the function that does the search, returning an array containing the result.
Call a JS function when the search button is clicked that builds the URL to generateTable.php, with the $_GET values included (/generateTable.php?device-name=foo&country=usa&store=3...). You can get the values from the fields using JQuery's .val() function, for instance var deviceName = $('#device-name').val();. This would require you to add id='device-name' to your input field named "device-name".
var deviceName = $('#device-name').val();
var country = $('#country').val();
var store = $('#store').val();
...
var generateTableUrl = "generateTable.php?device-name=" + deviceName + "&country=" + country + "&store=" + store...
With JQuery AJAX, you can load the output from generateTable.php with the following JS code:
$('#device-list_table').load(generateTableUrl);
The whole script becomes
function getSearchResults() {
var deviceName = $('#device-name').val();
var country = $('#country').val();
var store = $('#store').val();
...
var generateTableUrl = "generateTable.php?device-name=" + deviceName + "&country=" + country + "&store=" + store...
$('#device-list_table').load(generateTableUrl);
}
And to start the whole process, add onClick='getSearchResults();'to your search button, namely the button that would be the submit button in a traditional form. Note that this process does not use the form in a traditional sense, as the form does not call 'generateTable.php' directly, it is simply used as a place to get input for the JS function that loads 'generateTable.php'.
I must apologise for the code simplification I had to do; I am not currently able to test my code, so what is written here is meant more as a general outline of what to do than a working example.
Here is link for your Question:
https://www.datatables.net/
This is really helpful for data tables search record without refreshing page.

Form POST not showing in controller

I am working with CodeIgniter, and I am trying to create a dynamically generated table that includes a checkbox, with values set to the id numbers of the row, in the first column of the row. When a single or multiple checkbox is checked, and the button clicked, I am trying to bring up a second form which consists of a couple of select fields and a textarea.
Ultimately, when I submit the form, I want the values of the checkboxes to be sent to my controller. However, currently I am only getting a false value when I check the values of the POST field in my controller.
Here is my current view code:
<form class="form" role="form" name="ticket_view" id="ticket_view" action="<?php echo site_url('example_controller/example_method'); ?>">
<div class='table-responsive text-left'>
<table class='table table-hover table-bordered table-condensed supportTable'>
<thead>
<th>Select</th>
<th>Id</th>
<th class="text-center">Status</th>
<th>Source</th>
</thead>
<tbody>
<?php foreach($examples as $example): ?>
<?php if ($example->type == "test): ?>
<tr class="<?php echo alternator('oddRow', '');?>">
<td class="text-center" style="width:60px;"><input type="checkbox" value="<?=$example->id;?>" name="supportTicketId[]" class="supportLogCheck"></td>
<td><a href=<?php echo site_url("example_controller/example_method/" . $example->idd); ?>>SUP-<?php echo $example->id; ?></a></td>
<td class="text-center">
<?php if ( ! $example->claimed): ?>
<span class="label label-danger">Unclaimed</span>
<?php else: ?>
<span class="label label-success">Claimed</span>
<?php endif; ?>
</td>
<td><?php if ($example->voicemail): ?>Voicemail <?php else: ?>Email <?php endif; ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="text-center">
<a class="btn btn-primary" id="firstButton" href="javascript:void(0);">First Button</a>
</div>
<div id="secondForm" class="alert alert-info col-md-4 col-md-offset-4" style="display:none; margin-top:10px;">
<div class="form-group">
<label for="closeIssue">Issue:</label>
<select name="issue" id="issue" class="form-control">
<option value="">Select an Issue</option>
<?php foreach ($issues as $issue): ?>
<option value="<?php echo ($e->emailIssueId); ?>"><?php echo ($issue->emailIssueDescription); ?></option>
<?php endforeach; ?>
</select>
<label for="closeAction">Action:</label>
<select name="action" id="action" class="form-control">
<option value="">Select an Action</option>
<?php foreach ($actions as $action): ?>
<option value="<?php echo ($action->emailActionId); ?>"><?php echo ($action->emailActionDescription); ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="assignNote">Note:</label>
<textarea name="assignNote" id="assignNote" class="form-control"></textarea>
</div>
<div class="text-center">
<input class="btn btn-primary" name="secondButton" type="submit" id="secondButton" value="second button">
</div>
</div>
</div>
</form>
So, in a nutshell, the table is wrapped in a form. The first button slides down a
div that is orginally hidden, that contains other form fields and a submit button. I want, when that submit button is clicked, for all form fields to post, including the id numbers of the checkboxes that are checked.
Any ideas why this isn't working? Any better suggestions?
Thank you for your help in advance!
You haven't defined method on your form, so it's probably passing the values via GET. You need to add the method="post" attribute in your form tag.

Categories