I am having an issue where we cannot join up our checkboxes with the other fields being passsed.
If we only check the second checkbox it will take the value of the first row select box.
The rows are joined up by the date e.g.2014-06-02, 2014-06-03
HTML
<input type="checkbox" name="date_choice[]" value="2014-06-02">
<select id="event_start" name="event_start[2014-06-02][]" onchange="area_choice_click()">
<option value="">Start Time</option>
<option value="01:00">1.00AM</option>
<option value="02:00">2.00AM</option>
<option value="03:00">3.00AM</option>
</select>
<select id="event_end" name="event_end[2014-06-02][]" onchange="area_choice_click()">
<option value="">End Time</option>
<option value="01:00">1.00AM</option>
<option value="02:00">2.00AM</option>
<option value="03:00">3.00AM</option>
</select>
<input type="checkbox" name="date_choice[]" value="2014-06-03">
<select id="event_start" name="event_start[2014-06-03][]" onchange="area_choice_click()">
<option value="">Start Time</option>
<option value="01:00">1.00AM</option>
<option value="02:00">2.00AM</option>
<option value="03:00">3.00AM</option>
</select>
<select id="event_end" name="event_end[2014-06-03][]" onchange="area_choice_click()">
<option value="">End Time</option>
<option value="01:00">1.00AM</option>
<option value="02:00">2.00AM</option>
<option value="03:00">3.00AM</option>
</select>
PHP
foreach($_POST['date_choice'] as $key=>$team_id){
$event_date = $_POST['date_choice'][$key];
echo"$event_date";
$event_start=$_POST['event_start'][$event_date][$key];
}
Related
I am.working on a user input availability database. I order to standardize the information, I want to use more than 1 mulitiple select inputs.
<form method="post" action=''example.php">
Gamerid:<input ="text" name ="gamerid"/></br>
Monday:<select name="monday[]" multiple="multiple">
<option>Select your availability</option>
<option value="4">4pm</option>
<option value="5">5pm</option>
<option value="6">6pm</option>
<option value="7">7pm</option>
<option value="8">8pm</option>
<option value="9">9pm</option>
<option value="10">10pm</option>
<option value="11">11pm</option>
<option value="12">12pm</option>
<option value="1a">1am</option>
</select> </br>
Tuesday:<select name="tuesday[]"multiple="multiple">
<option>Select your availability</option>
<option value="4">4pm</option>
<option value="5">5pm</option>
<option value="6">6pm</option>
<option value="7">7pm</option>
<option value="8">8pm</option>
<option value="9">9pm</option>
<option value="10">10pm</option>
<option value="11">11pm</option>
<option value="12">12pm</option>
<option value="1a">1am</option>
</select> </br>
Wednesday:<select name="wednesday[]" multiple="multiple">
<option>Select your availability</option>
<option value="4">4pm</option>
<option value="5">5pm</option>
<option value="6">6pm</option>
<option value="7">7pm</option>
<option value="8">8pm</option>
<option value="9">9pm</option>
<option value="10">10pm</option>
<option value="11">11pm</option>
<option value="12">12pm</option>
<option value="1a">1am</option>
</select> </br>
etc for every day of the week.. so far, I believe my code is correct but POST seems to not appreciate it. Is it even possible..?
The end goal it to serialise the $_POST arrays, into strings, then store them in sql db.
Any help here would be appreciated.
In action page you will get array then by using implode you can convert to string then you can insert in to database.
try for this code.
<form method="post">
Tuesday:<select name="tuesday[]"multiple="multiple">
<option>Select your availability</option>
<option value="4">4pm</option>
<option value="5">5pm</option>
<option value="6">6pm</option>
<option value="7">7pm</option>
<option value="8">8pm</option>
<option value="9">9pm</option>
<option value="10">10pm</option>
<option value="11">11pm</option>
<option value="12">12pm</option>
<option value="1a">1am</option>
</select>
<input type="submit" name="submit">
</form>
<?php
if(isset($_POST['submit'])){
$var=$_POST['tuesday'];
echo implode(",",$var);
}
?>
I have a form where users have dropdowns.. The form have a get method so that the output values is used for processing.. But the problem is i get all the three values which is not able to be used..
<form method="get" action="finish.php">
<select name="case" >
<option value="">*Grimsborough Case*</option>
<option value="1" >001</option>
<option value="2" >002</option>
<option value="3" >003</option>
</select>
<select name="case" >
<option value="">*Pacific Bay Case*</option>
<option value="201" >PB01</option>
<option value="202" >PB02</option>
<option value="203" >PB03</option>
</select>
<select name="case" >
<option value="">*World Edition Case*</option>
<option value="301" >WE01</option>
<option value="302" >WE02</option>
<option value="303" >WE03</option>
</select>
These are the forms that I have the output while i select is something like this..
finish.php?case=&case=&case=302&submit=%3D%3D>+submit+<%3D%3D
I will like to get output like this
finish.php?case=302&submit=%3D%3D>+submit+<%3D%3D
Please help :)
You need to name your select elements differently
<form method="get" action="finish.php">
<select name="case1" >
<option value="">*Grimsborough Case*</option>
<option value="1" >001</option>
<option value="2" >002</option>
<option value="3" >003</option>
</select>
<select name="case2" >
<option value="">*Pacific Bay Case*</option>
<option value="201" >PB01</option>
<option value="202" >PB02</option>
<option value="203" >PB03</option>
</select>
<select name="case3" >
<option value="">*World Edition Case*</option>
<option value="301" >WE01</option>
<option value="302" >WE02</option>
<option value="303" >WE03</option>
</select>
And from your php script, you to do this:
$case1 = $_GET["case1"];
$case2 = $_GET["case2"];
$case3 = $_GET["case3"];
If i understood it right you want something like that:
<select name="case" >
<optgroup label="Grimsborough Case">
<option value="1" >001</option>
<option value="2" >002</option>
<option value="3" >003</option>
</optgroup>
<optgroup label="Pacific Bay Case">
<option value="201" >PB01</option>
<option value="202" >PB02</option>
<option value="203" >PB03</option>
</optgroup>
<optgroup label="World Edition Case">
<option value="301" >WE01</option>
<option value="302" >WE02</option>
<option value="303" >WE03</option>
</optgroup>
</select>
This is what I got so far, it's just the dropdown list. It's a form for making a reservation for appointment. I want to print out these selected values (= selected options of dropdown)
But I have no clue since I'm very new with PHP and HTML. Something with $_POST and $_GET ? Could I have some suggestions of solution? Much gratitude.
<html>
<head>
<title>title</title>
</head>
<body>
<select name="Ar" id="Ar">
<option value="1">2014</option>
<option value="2">2015</option>
<option value="3">2016</option>
<option value="4">2017</option>
<option value="5">2018</option>
<option value="6">2019</option>
</select>
<select name="Manad" id="Manad">
<option value="1">Januari</option>
<option value="2">Februari</option>
<option value="3">Mars</option>
<option value="4">April</option>
<option value="5">Maj</option>
<option value="6">Juni</option>
<option value="7">July</option>
<option value="8">Augusti</option>
<option value="9">September</option>
<option value="10">Oktober</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="Dag" id="Dag">
<option value="1">Mandag</option>
<option value="2">Tisdag</option>
<option value="3">Onsdag</option>
<option value="4">Torsdag</option>
<option value="5">Fredag</option>
</select>
<select name="Tid" id="Tid">
<option value="1">07:00</option>
<option value="2">08:00</option>
<option value="3">09:00</option>
<option value="4">10:00</option>
<option value="5">11:00</option>
<option value="6">12:00</option>
<option value="7">13:00</option>
<option value="8">14:00</option>
<option value="9">15:00</option>
<option value="10">16:00</option>
<option value="11">17:00</option>
<option value="12">18:00</option>
</select>
<input type="submit" name="submit" id="submit" value="Boka" />
</body>
</html>
You're missing the <form> tag. It should be wrapped around all your form-data (select, input) etc. Then you will fetch it using either $_GET or $_POST or even $_REQUIRE
Example (change site.php to whatever you please):
<html>
<head>
<title>title</title>
</head>
<body>
<form method="post" action="site.php">
<select name="Ar" id="Ar">
<option value="1">2014</option>
<option value="2">2015</option>
<option value="3">2016</option>
<option value="4">2017</option>
<option value="5">2018</option>
<option value="6">2019</option>
</select>
<select name="Manad" id="Manad">
<option value="1">Januari</option>
<option value="2">Februari</option>
<option value="3">Mars</option>
<option value="4">April</option>
<option value="5">Maj</option>
<option value="6">Juni</option>
<option value="7">July</option>
<option value="8">Augusti</option>
<option value="9">September</option>
<option value="10">Oktober</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="Dag" id="Dag">
<option value="1">Mandag</option>
<option value="2">Tisdag</option>
<option value="3">Onsdag</option>
<option value="4">Torsdag</option>
<option value="5">Fredag</option>
</select>
<select name="Tid" id="Tid">
<option value="1">07:00</option>
<option value="2">08:00</option>
<option value="3">09:00</option>
<option value="4">10:00</option>
<option value="5">11:00</option>
<option value="6">12:00</option>
<option value="7">13:00</option>
<option value="8">14:00</option>
<option value="9">15:00</option>
<option value="10">16:00</option>
<option value="11">17:00</option>
<option value="12">18:00</option>
</select>
<input type="submit" name="submit" id="submit" value="Boka" />
</form>
</body>
</html>
PHP example:
if(isset($_POST['Ar'])) { // Make sure it's sent
$year = $_POST['Ar'];
echo "År: " . htmlentities($year); // Output (htmlentities for safety when outputting)
$month = $_POST['Manad'];
echo "Månad: " . htmlentities($month);
}
so I have a multi-select listbox...
<select id="extfeat" name="extfeat[]" size="6" multiple="">
<option value="Wheel_Chair Accessible">Wheel Chair Accessible</option>
<option value="Fruit_Trees">Fruit Trees</option>
<option value="Large_Trees">Large Trees</option>
<option value="Rolling">Rolling</option>
<option value="Other">Other</option>
<option value="Level">Level</option>
<option value="Wooded">Wooded</option>
<option value="Outbuildings">Outbuildings</option>
<option value="Gazebo">Gazebo</option>
<option value="Workshop Area">Workshop Area</option>
<option value="Sauna">Sauna</option>
<option value="Courtyard">Courtyard</option>
<option value="Lake_Access">Lake Access</option>
<option value="Tillable">Tillable</option>
<option value="Deck">Deck</option>
<option value="Lakeview">Lakeview</option>
<option value="Propane_Tank_-_Leased">Propane Tank - Leased</option>
<option value="Dock">Dock</option>
<option value="Landscaped">Landscaped</option>
<option value="Propane_Tank - Owned">Propane Tank - Owned</option>
<option value="Fenced_Yard">Fenced Yard</option>
<option value="Water_Frontage">Water Frontage</option>
<option value="Concrete_Parking">Concrete Parking</option>
<option value="Pond">Pond</option>
<option value="Tennis_Court">Tennis Court</option>
<option value="Circle_Drive">Circle Drive</option>
<option value="Horses_Allowed">Horses Allowed</option>
<option value="Patio_Enclosed">Patio Enclosed</option>
<option value="Sprinkler_System">Sprinkler System</option>
<option value="Brick_Trim">Brick Trim</option>
<option value="Guest_House">Guest House</option>
<option value="Terraced">Terraced</option>
<option value="Hot_Tub">Hot Tub</option>
<option value="Outdoor_Sign">Outdoor Sign</option>
<option value="Garden">Garden</option>
<option value="Above_ground_pool">Above ground pool</option>
<option value="Ground_Lvl_Access">Ground Lvl Access</option>
<option value="Handicap_Access">Handicap Access</option>
<option value="Patio">Patio</option>
<option value="Garage_Opener">Garage Opener</option>
<option value="In-ground_Pool">In-ground Pool</option>
<option value="Greenhouse">Greenhouse</option>
<option value="Pasture">Pasture</option>
<option value="Shed">Shed</option>
<option value="Boat_House">Boat House</option>
<option value="Antenna">Antenna</option>
<option value="Generator">Generator</option>
<option value="Asphalt_Parking">Asphalt Parking</option>
<option value="Sloping">Sloping</option>
<option value="Porch">Porch</option>
<option value="Satellite_Dish">Satellite Dish</option>
<option value="Screened_Porch">Screened Porch</option>
<option value="Underground_Pet_Fence">Underground Pet Fence</option>
<option value="Pool">Pool</option>
</select>
so lets say a user selects 7 options and does a search...my search has a refine option and this along with many other fields are saved and stored in a hidden div that can be brought up again by pressing a button...
the problem is that the extfeats[] variable isn't retaining the selections after the POST...i need to somehow transfer the existing multiselections as the defaults.
If you know which options were selected you can mark them as selected by default with: selected="selected":
<select id="extfeat" name="extfeat[]" size="6" multiple="">
<option value="Wheel_Chair Accessible">Wheel Chair Accessible</option>
<option value="Fruit_Trees" selected="selected">Fruit Trees</option>
// ..
</select>
On a minor note multiple="" should probably be multiple="multiple".
ok...well it turned out to be easier then i thought...
<select id="extfeat" name="extfeat[]" size="6" multiple="">
<option value="Wheel_Chair Accessible" <? if (in_array("Wheel_Chair Accessible",$extfeat)) echo "selected" ?> >Wheel Chair Accessible</option>
<option value="Fruit_Trees" <? if (in_array("Fruit_Trees",$extfeat)) echo "selected" ?>>Fruit Trees</option>
...
thxs to Frits van Campen for your gentle push in the right direction ;)
I have the following date picker with 3 different select ids
<form id="testform" method="get" action="../Untitled-1.html">
<select id="date-sel-dd" name="date-sel-dd">
<option value="-1">Day</option>
<option value="1">1st</option>
<option value="2">2nd</option>
<option value="3">3rd</option>
<option value="4">4th</option>
<option value="5">5th</option>
<option value="6">6th</option>
<option value="7">7th</option>
<option value="8">8th</option>
<option value="9">9th</option>
<option value="10">10th</option>
<option value="11">11th</option>
<option value="12">12th</option>
<option value="13">13th</option>
<option value="14">14th</option>
<option value="15">15th</option>
<option value="16">16th</option>
<option value="17">17th</option>
<option value="18">18th</option>
<option value="19">19th</option>
<option value="20">20th</option>
<option value="21">21st</option>
<option value="22">22nd</option>
<option value="23">23rd</option>
<option value="24">24th</option>
<option value="25">25th</option>
<option value="26">26th</option>
<option value="27">27th</option>
<option value="28">28th</option>
<option value="29">29th</option>
<option value="30">30th</option>
<option value="31">31st</option>
</select>
<select id="date-sel-mm" name="date-sel-mm">
<option value="-1">Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select id="date-sel" name="date-sel">
<option value="-1">Year</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
</select>
<input type="submit" name="submit" id="submit" value="Submit" />
I need to get the values from these 3 differnt select fields and post it with the form to a new named: 'arrival'.
When I submit to the page I want my url to look like:
mydomain.php?arrival=date-sel-dd/date-sel-mm/date-sel
You could use an array.
Rename all select with arrival[].
In your php page you can get that value as an array. Try:
print_r($_POST['arrival']);
If you want to join the date use:
$date = implode('/', $_POST['arrival']);
header('Location: mydomain.php?arrival=' . $date);