Reputation: 4893
Below code is one.php. i want to take text as will as value and to next page send_mail.php using POST/GET.
so how it can be done?
<form action="send_mail.php" name="choose_aff" method="POST">
<select name="company" id="company" class="company_select" style="width:250px;" onchange="submit()">
<option value="">Select</option>
<option value="123">abc</option>
<option value="354">xyz</option>
</select>
</form>
Upvotes: 1
Views: 681
Reputation: 2785
<form action="test1.php" name="choose_aff" method="POST">
<select name="company" id="company" class="company_select" style="width:250px;" onchange=" document.getElementById('text_content').value=this.options[this.selectedIndex].text">
<option value="">Select</option>
<option value="123">abc</option>
<option value="354">xyz</option>
</select>
<input type="hidden" name="test_text" id="text_content" value="" />
<input type="submit" name="submit" value="submit">
</form>
PHP Code
echo $_POST['company'];
echo $_POST['test_text'];
Upvotes: 2
Reputation: 944016
You created the form in the first place. You already have the information needed to associate 123 with abc and 345 with xyz.
Include that information in the program which is processing the form (you could hard code it as an associative array or store it in a database).
Then just look it up:
$number = $_POST['company'];
$letters = $my_map[$number];
Upvotes: 0
Reputation: 2036
you can create hidden inputs
<input type="hidden" id="companyName" value="">
<input type="hidden" id="companyId" value="">
then on drop down change you can set these hidden inputs
$(function() {
$("#company").change(function() {
var companyName = $('#company:selected').text();
var companyId = $('#company').val();
$('#companyName').val(companyName);
$('#companyId').val(companyId );
});
});
then when you submit your form you can get values like
$companyName = $_POST['companyName '];
$companyId = $_POST['companyId '];
Upvotes: 0