I wonder if anyone can help my problem, in which way I can get value from combobox selection into next url by clicking so I can make it as a parameter to the pdf report.
this is my code to add some combobox :
<form method="GET">
<label class="col-sm-3 control-label">Bulan</label>
<div class="col-sm-2">
<select name="bln" class="form-control">
<option value="1">Januari</option>
<option value="2">Februari</option>
<option value="3">Maret</option>
<option value="4">April</option>
<option value="5">Mei</option>
<option value="6">Juni</option>
<option value="7">Juli</option>
<option value="8">Agustus</option>
<option value="9">September</option>
<option value="10">Oktober</option>
<option value="11">November</option>
<option value="12">Desember</option>
</select>
</div>
<br>
<br>
<label class="col-sm-3 control-label">Tahun</label>
<div class="col-sm-2">
<select name="thn" class="form-control">
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
<option value="2025">2025</option>
</select>
</div>
</form>
<?php
if (isset($_GET['bln'])) {
$bln = $_GET['bln'];
$thn = $_GET['thn'];
}
?>
<a class="btn btn-success" href="rep-cuti-tahunan-all.php?bln="$bln"&thn="$thn"">Print</a>
so I would like to put $bln and $thn into <a class="btn btn-success" href="rep-cuti-tahunan-all.php?bln="$bln"&thn="$thn"">Print</a>
and get my report in pdf exactly according to that parameters
any suggestions?
You don't have to add it as a parameter.Just change your form like this.
<form method="GET" action ="rep-cuti-tahunan-all.php">
....
</form>
then on your php file, you fetch the selected value.
<?php
....
if (isset($_GET['bln'])) {
$bln = $_GET['bln'];
$thn = $_GET['thn'];
}
....
//Do your print method ...
?>
Related
I want to echo selected value from dropdown. But it always give me the output: Default
Kindly check what I am doing:
<div>
<select id="orderStatus" name="orderStatus">
<option value="0"></option>
<option value="Available">Available</option>
<option value="Arranging Product">Arranging Product</option>
<option value="Awaiting Fulfillment">Awaiting Fulfillment</option>
<option value="Awaiting Payment">Awaiting Payment</option>
<option value="Awaiting Pickup">Awaiting Pickup</option>
<option value="Awaiting Shipment">Awaiting Shipment</option>
</select>
// I think here is the problem when I click button it forgets selected index value
Update
</div>
Php Code:
<?php
$draft = isset($_GET['orderStatus'])? $_GET['orderStatus'] : 'DEFAULT';
echo $draft;
?>
When I click on update button then in the output I always get DEFAULT. I think when I click on the update button it forgets the selected index value.
Kindly suggest what I am doing wrong.
Add to tag onmousedown event:
<div>
<select id="orderStatus" name="orderStatus">
<option value="0"></option>
<option value="Available">Available</option>
<option value="Arranging Product">Arranging Product</option>
<option value="Awaiting Fulfillment">Awaiting Fulfillment</option>
<option value="Awaiting Payment">Awaiting Payment</option>
<option value="Awaiting Pickup">Awaiting Pickup</option>
<option value="Awaiting Shipment">Awaiting Shipment</option>
</select>
// I think here is the problem when I click button it forgets selected index value
Update
</div>
This send your parametr as GET request
<div>
<form method="GET" action="order.php">
<select id="orderStatus" name="orderStatus">
<option value="0"></option>
<option value="Available">Available</option>
<option value="Arranging Product">Arranging Product</option>
<option value="Awaiting Fulfillment">Awaiting Fulfillment</option>
<option value="Awaiting Payment">Awaiting Payment</option>
<option value="Awaiting Pickup">Awaiting Pickup</option>
<option value="Awaiting Shipment">Awaiting Shipment</option>
</select>
<button type="submit" class="btn btn-large">Update</button>
</form>
</div>
Try This , Its working :
<?php
if(isset($_POST['submit'])){
$value = $_POST['orderStatus'];
echo $value;
}
?>
<form action="" method="post">
<select id="orderStatus" name="orderStatus">
<option value="0"></option>
<option value="Available">Available</option>
<option value="Arranging Product">Arranging Product</option>
<option value="Awaiting Fulfillment">Awaiting Fulfillment</option>
<option value="Awaiting Payment">Awaiting Payment</option>
<option value="Awaiting Pickup">Awaiting Pickup</option>
<option value="Awaiting Shipment">Awaiting Shipment</option>
</select>
<input type="submit" name="submit" value="Update" />
</form>
I've been trying to post the value of two selected dropdown menu's using the SESSIONS method, however there seems to be an issue because when submitted the second page displays the PHP code only. Here are the relevant snippets of code:
shop.php
<form action="processing.php" method="post"> <div class="item">
<span class="caption">Essential Gray Suit<br />£459</span>
<select name="size1" class="size" id="size1" onchange="showDiv(this)">
<optgroup label="Size">
<option value="0">SELECT SIZE</option>
<option value="1">XS</option>
<option value="2">S</option>
<option value="3">M</option>
<option value="4">L</option>
<option value="5">XL</option>
</select>
<div id="quantity1" style="display: none;">
<select name="quantity1" class="size" onchange="showCart(this)">
<optgroup label="Quantity">
<option value="0">SELECT QUANTITY</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<input type="submit" value="Submit" name="submit" id="submit">
</form>
processing.php
<?php
session_start();
if (isset($_POST['submit'])) {
$_SESSION['size1'] = $_POST['size1'];
}
echo $_SESSION['size1'];
?>
I'm creating a system which provide a report generator, now my problem is i dont know how to call data with the variables that i want. For example I only want the data from January // 2014 // from the account department and so on. Now, i don't know what code to show but below is the menu where user select their variables
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
function showForm() {
var selopt = document.getElementById("opts").value;
if (selopt == "Tenaga Nasional Berhad") {
document.getElementById("f1").style.display = "block";
document.getElementById("f2").style.display = "none";
}
if (selopt == "Telekom Malaysia") {
document.getElementById("f2").style.display = "block";
document.getElementById("f1").style.display = "none";
}
if (selopt == 0) {
document.getElementById("f2").style.display = "none";
document.getElementById("f1").style.display = "none";
}
}
</script>
<div id="contact_form">
<h4>Pilih Ketetapan Laporan</h4>
<form method="post" name="pilih_kategori_daftar">
<label for="daerah">Daerah:</label>
<select class="required input_field" name="daerah" id="daerah" required/>
<option value="">--Pilih Daerah--</option>
<option value="Kuantan">Kuantan</option>
<option value="Maran">Maran</option>
<option value="Bentong">Bentong</option>
<option value="Raub">Lipis</option>
<option value="Jerantut">Jerantut</option>
<option value="Cameron Highlands">Cameron Highlands</option>
<option value="P.Tenggara">Pahang Tenggara</option>
<option value="Pekan">Pekan</option>
<option value="Rompin">Rompin</option>
<option value="Temerloh">Temerloh</option>
<option value="Bera">Bera</option>
<option value="Ibu Pejabat">Ibu Pejabat</option>
</select>
<div class="cleaner_h10"></div>
<label for="bulan_bill">Bulan</label>
<select class="required bill_caj" name="bulan_bill" id="bulan_bill" width="300px" required/>
<option value="">--Pilih Bulan--</option>
<option value="Januari">Januari</option>
<option value="Februari">Februari</option>
<option value="Mac">Mac</option>
<option value="April">April</option>
<option value="Mei">Mei</option>
<option value="Jun">Jun</option>
<option value="Julai">Julai</option>
<option value="Ogos">Ogos</option>
<option value="September">September</option>
<option value="Oktober">Oktober</option>
<option value="November">November</option>
<option value="Disember">Disember</option>
</select>
<div class="cleaner_h10"></div>
<label for="tahun_bill">Tahun</label>
<input type="text" maxlength="4" size="4" id="tahun_bill" name="tahun_bill" class="required year_field" placeholder="Tahun" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" required/>
<div class="cleaner_h10"></div>
<label for="kategori_akaun">Kategori</label>
<select id="opts" onchange="showForm()" class="input_field" required>
<option value="0">--Pilih Kategori--</option>
<option value="Tenaga Nasional Berhad">Akaun TNB</option>
<option value="Telekom Malaysia">Akaun TM</option>
</select>
<div class="cleaner_h10"></div>
<div id="f1" style="display:none">
<form name="akaun_tnb">
<label for="jenis">Jenis Akaun</label>
<select id="opts" onchange="showForm()"class="input_field">
<option value="0">--Pilih Jenis Akaun--</option>
<option value="Rumah Pam">Rumah Pam</option>
<option value="Loji Air">Loji Air</option>
<option value="Stor">Stor</option>
</select>
</form>
</div>
<div id="f2" style="display:none">
<form name="akaun_tm">
<label for="jenis">Jenis Akaun</label>
<select id="opts" onchange="showForm()"class="input_field">
<option value="0">--Pilih Jenis Akaun--</option>
<option value="Telefon">Telefon</option>
<option value="Telefon/Streamyx">Telefon/Streamyx</option>
<option value="Streamyx">Streamyx</option>
<option value="SMS Blast">SMS Blast</option>
<option value="TM NET">TM NET</option>
</select>
</form>
</div>
</form>
</div>
search in google:
1, How to create mysqli database, tables, columns.
2, PHP, how to connect, extract, insert data from mysqli using php,
3. How to echo mysqli data into html, 4. how to submit form to php and insert data to mysqli, 5. Learn to use AJAX & JSON...this you may leave for few months:)
i have one big form.. there have some so many select option. and its from to mail function. bellow is my code
<label>Type of Event? </label>
<select id="eventtype" title="" name="eventtype" class="required select">
<option value="">Select Your Event Type</option>
<option value="WEDDINGS">WEDDINGS</option>
<option value="CORPORATE">CORPORATE EVENT</option>
<option value="SPECIAL">SPECIAL EVENT</option>
<option value="OTHER">OTHER SINGLE SERVICES</option>
</select>
<div class="cls"></div>
<div class="container">
<div class="WEDDINGS">
<label>Package</label>
<select name="Package" id="Package">
<option value="Day Of Coordination">Day Of Coordination</option>
<option value="Week of Coordination">Week of Coordination</option>
<option value="Month of Coordination">Month of Coordination</option>
</select>
</div>
<div class="CORPORATE">
<label>Package</label>
<select name="Package" id="Package">
<option value="Meetings">Meetings</option>
<option value="Client Appreciation">Client Appreciation</option>
<option value="Conference & Conventions">Conference & Conventions</option>
<option value="Corporate Shows">Corporate Shows</option>
<option value="Employee Appreciation">Employee Appreciation</option>
</select>
</div>
<div class="SPECIAL">
<label>Package</label>
<select name="Package" id="Package">
<option value="Engagements">Engagements</option>
<option value="Bar Mitzvah">Bar Mitzvah</option>
<option value="Quincearas">Quincearas</option>
<option value="Birthdays">Birthdays</option>
<option value="Fashion Shows">Fashion Shows</option>
<option value="Showers">Showers</option>
</select>
</div>
<div class="OTHER">
<label>Package</label>
<select name="Package" id="Package">
<option value="Wedding Consultation and Guidance Only">Wedding Consultation and Guidance Only</option>
<option value="Venue Search Only">Venue Search Only</option>
<option value="Coordination of Engagement Party Only">Coordination of Engagement Party Only</option>
<option value="Providing Qualified and Screened Vendors Only">Providing Qualified and Screened Vendors Only</option>
</select>
js code for realtion with drop down
<script>
$(document).ready(function() {
$('#eventtype').bind('change', function() {
var elements = $('div.container').children().hide();
var value = $(this).val();
if (value.length) {
elements.filter('.' + value).show();
}
}).trigger('change');
});
</script>
my from is like if select WEDDING then show Wedding div so show there another drop down.. and if select CORPORATE EVENT then show CORPORATE EVENT div... but no matter what drop down i select when mail go correct data not pass. its goes always OTHER div 1st select value mean "Wedding Consultation and Guidance Only" ... i have no idea why... may be i mistake something... bellow is part of php mail code
if($violation)
{
$eventtype = $_POST['eventtype'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$datepicker = $_POST['datepicker'];
$datepicker2 = $_POST['datepicker2'];
$time = $_POST['time'];
$EMAIL = $_POST['EMAIL'];
$phone = $_POST['phone'];
$Package = $_POST['Package'];
$otherfound = $_POST['otherfound'];
if (isset($_POST['found_group'])) {
$found = $_POST['found_group'];
for ($i=0; $i<count($found); $i++) {
//echo $found[$i]."<br />";
$found=implode("<br />",$found);
}
}
all i want to correct data will go .. can you tell me where i am mistaking... thanks
you may need to do something like this
<label>Type of Event? </label>
<select id="eventtype" title="" name="eventtype" name="eventtype" class="required select">
<option value="">Select Your Event Type</option>
<option value="WEDDINGS">WEDDINGS</option>
<option value="CORPORATE">CORPORATE EVENT</option>
<option value="SPECIAL">SPECIAL EVENT</option>
<option value="OTHER">OTHER SINGLE SERVICES</option>
</select>
<div class="cls"></div>
<div class="container">
<div class="WEDDINGS">
<label>Package</label>
<select name="WEDDINGSPackage" id="WEDDINGSPackage">
<option value="Day Of Coordination">Day Of Coordination</option>
<option value="Week of Coordination">Week of Coordination</option>
<option value="Month of Coordination">Month of Coordination</option>
</select>
</div>
<div class="CORPORATE">
<label>Package</label>
<select name="CORPORATEPackage" id="CORPORATEPackage">
<option value="Meetings">Meetings</option>
<option value="Client Appreciation">Client Appreciation</option>
<option value="Conference & Conventions">Conference & Conventions</option>
<option value="Corporate Shows">Corporate Shows</option>
<option value="Employee Appreciation">Employee Appreciation</option>
</select>
</div>
.......
and at PHP end you have to do something like this
if (isset($_POST['eventtype'])) {
$subOptSelect = $_POST['eventtype'] . 'Package';
if (isset($_POST[$subOptSelect])){
$sub = $_POST[$subOptSelect];
}
}
I have prefixed the value of the first select to the sub selects and it becomes easier at php end.
Edit: Here is the code you may require.
$package='';
if (!empty($eventtype)) {
if (!empty($_POST[$eventtype.'Package'])){
$package = $_POST[$eventtype.'Package'];
//$package contains the option selected in the sub option.
}else{
//nothing selected in the sub dropdown. you have to add code to handle this
}
}else{
//nothing selected in the first dropdown. you have to add code to handle this
}
And your email can be:
<table width='95%' cellpadding='0' cellspacing='11'>
<tr>
<td width='189'>Event Type :</td>
<td>$eventtype</td>
</tr>
<tr>
<td>Package :</td><td>$package</td>
</tr>
<tr>
<td>First Name :</td><td>$firstname</td>
</tr>
<tr>
You can't reuse the name attribute in html, and you're html form has the same name for each select tag. What is happening is the markup is processed sequentially so it only uses the last declaration of the name="Package" select so the selected value from that will always be passed to the server as the $_POST['package']. Do something like this instead:
<label>Type of Event? </label>
<select id="eventtype" title="" name="eventtype" class="required select">
<option value="">Select Your Event Type</option>
<option value="WEDDINGS">WEDDINGS</option>
<option value="CORPORATE">CORPORATE EVENT</option>
<option value="SPECIAL">SPECIAL EVENT</option>
<option value="OTHER">OTHER SINGLE SERVICES</option>
</select>
<div class="cls"></div>
<div class="container">
<div class="WEDDINGS">
<label>Package</label>
<select name="Weddings-Package" id="Weddings-Package">
<option value="Day Of Coordination">Day Of Coordination</option>
<option value="Week of Coordination">Week of Coordination</option>
<option value="Month of Coordination">Month of Coordination</option>
</select>
</div>
<div class="CORPORATE">
<label>Package</label>
<select name="Corporate-Package" id="Corporate-Package">
<option value="Meetings">Meetings</option>
<option value="Client Appreciation">Client Appreciation</option>
<option value="Conference & Conventions">Conference & Conventions</option>
<option value="Corporate Shows">Corporate Shows</option>
<option value="Employee Appreciation">Employee Appreciation</option>
</select>
</div>
<div class="SPECIAL">
<label>Package</label>
<select name="Special-Package" id="Special-Package">
<option value="Engagements">Engagements</option>
<option value="Bar Mitzvah">Bar Mitzvah</option>
<option value="Quincearas">Quincearas</option>
<option value="Birthdays">Birthdays</option>
<option value="Fashion Shows">Fashion Shows</option>
<option value="Showers">Showers</option>
</select>
</div>
<div class="OTHER">
<label>Package</label>
<select name="Other-Package" id="Other-Package">
<option value="Wedding Consultation and Guidance Only">Wedding Consultation and Guidance Only</option>
<option value="Venue Search Only">Venue Search Only</option>
<option value="Coordination of Engagement Party Only">Coordination of Engagement Party Only</option>
<option value="Providing Qualified and Screened Vendors Only">Providing Qualified and Screened Vendors Only</option>
</select>
when the post data is sent to the server it is sent in the $_POST variable as an associative array with the names as the key, if you make the name of each select unique then you should be able to achieve what you want. You might want to pass the name of which select was used to the server so you know which variable to grab in php. As another note the id value for every tag should be unique, as that is the purpose of an id attribute.
Im trying to get form post values and if they match certain criteria redirect only my page doesnt seem to...
I have a form with multiple input fields
HTML
<form method="post" action="?page_id=151">
<div style="display: block;" id="Q1">
<label for="vehicleType">1. What type of vehicles do you have?</label>
<select id="vehicleType" name="vehicleType">
<option selected="selected" value="choose">Please choose</option>
<option value="hgv">HGV</option>
<option value="psv">PSV</option>
<option value="lgv">LGV</option>
<option value="car">Car</option>
<option value="mixed">Mixed Fleet</option>
</select>
</div>
<div id="Q2group1">
<label for="coverageRegion">2. Do you require national or international coverage?</label>
<select id="coverageRegion" name="coverageRegion">
<option selected="selected" value="choose">Please choose</option>
<option value="national">National</option>
<option value="international">International</option>
</select>
</div>
<div id="Q2others">
<label for="pricing">2. Do you prefer a fixed weekly price or a pump-related price?</label>
<select id="pricing" name="pricing">
<option selected="selected" value="choose">Please choose</option>
<option value="fixed">Weekly fixed price</option>
<option value="pump">Pump-related price</option>
</select>
</div>
<div id="Q3group1">
<label for="locationType">3. What type of site do you prefer?</label>
<select id="locationType" name="locationType">
<option selected="selected" value="choose">Please choose</option>
<option value="truckstops">Truck stops at lowest price</option>
<option value="motorway">Branded motorway sites</option>
</select>
</div>
<div id="Q3others">
<label for="siteCoverage">3. What site coverage do you need?</label>
<select id="siteCoverage" name="siteCoverage">
<option value="choose">Please choose</option>
<option value="countysites">County</option>
<option value="nationalsites">National</option>
</select>
</div>
<div id="Q4others">
<label for="county">4. Select your county:</label>
<select id="county" name="county">
<option value="choose">Please choose</option>
<optgroup label="England">
<option>Bedfordshire</option>
<option>Berkshire</option>
<option>Bristol</option>
<option>Tyrone</option>
</optgroup>
</select></div>
<div id="searchbuttondiv"> <input type="submit" id="searchbutton" onclick="_gaq.push(['_trackEvent', 'Fuel Card Search', 'Homepage Select Criteria'])"> </div>
</form>
PHP
if ($_POST['vehicleType'] == 'car' && $_POST['pricing'] == 'fixed' && $_POST['coverageRegion'] == 'national') {
echo '<script>alert("hi");</script>';
// header('Location: /car-weekly-national/');
}
One of your conditions is falling (and because they are all bound by AND, all of the if statement fails.
Have an else statement where you var_dump all relevant variables and see what's wrong.
Sorry everyone, oversight by me, I was checking to see if the wrong variable had been posted, wouldn't have found it if it wasn't for the suggestions to add an else statement, thanks!