1 Replies - 197 Views - Last Post: 20 August 2012 - 06:11 AM Rate Topic: -----

#1 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 559
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Submit action on two different options

Posted 20 August 2012 - 02:54 AM

Hi guys, trying to figure something out without success. I have a field in the form like so
<div id="date">
    <input type="text" name="departdate" id="departdate" class="datepicker" value="Depart" />
    <input type="text" name="returndate" id="returndate" class="datepicker" value="Return" />
	<select name="departdate_day" class="mobile-datepicker">
		<?php
			$i=1;
			while($i < 32){
				echo "<option>".$i."</option>";
				$i++;
			}
		?>
	</select>
	<select name="departdate_monthyear" class="mobile-datepicker">
		<?php
			$i=0;
			while($i < 25){
				echo "<option>".date("M Y",strtotime(+$i." month"))."</option>";
				$i++;
			}
		?>
	</select>
	<select name="returndate_day" class="mobile-datepicker">
		<?php
			$i=1;
			while($i < 32){
				echo "<option>".$i."</option>";
				$i++;
			}
		?>
	</select>
	<select name="returndate_monthyear" class="mobile-datepicker">
		<?php
			$i=0;
			while($i < 25){
				echo "<option>".date("M Y",strtotime(+$i." month"))."</option>";
				$i++;
			}
		?>
	</select>
    <span id="travelDate" style="height:16px;">&nbsp;&nbsp;&nbsp;&nbsp;</span>
  </div>


Now what happens with the above, departdate and returndate display the JQuery calandar. As this calander was to much for the mobile version of my site, I added departdate_day and departdate_monthyear (same for return) which displays a select version of the calandar. Using css, I display none on the select calandar when the large version of the site is viewed, and I set display none to the JQuery calandar once the resolution goes to a mobile size.

The problem I am having relates now to the submit action using php. At the moment, I only handle things for the large version of my site using
$departdate= $_POST['departdate'];
$departarray = explode("/",$departdate);
$departdate = strtotime($departarray[2]."-".$departarray[1]."-".$departarray[0]);

$returndate=$_POST['returndate'];
$returndatearray = explode("/",$returndate);
$returndate = strtotime($returndatearray[2]."-".$returndatearray[1]."-".$returndatearray[0]);


I then send all the information to my database and so forth. How would I go ahead handling the other version of my calandar? I would presume that I would need to use conditional statements to check the size of the resolution, I want to avoid this however as I dont really want several different languages all checking the resolution, incase there is a disagreement :surrender:

Could I check to see what calanadar is being used somehow, or something along these lines? Any advise as always appreciated.

Cheers

Nick

Is This A Good Question/Topic? 0
  • +

Replies To: Submit action on two different options

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2486
  • View blog
  • Posts: 8,531
  • Joined: 08-August 08

Re: Submit action on two different options

Posted 20 August 2012 - 06:11 AM

First, why don't you go directly to time:
$departdate= strtotime($_POST['departdate']);


Second, can't you make calendar version a parameter sent to PHP?

This post has been edited by CTphpnwb: 20 August 2012 - 06:12 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1