Jump to content

Grab the date var using datepicker

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Thevenin

Thevenin

    Learning Programmer

  • Members
  • PipPipPip
  • 58 posts
Hi all, unfortunately I don't know where exactly I could post this question, it's borderline. Because I'm using the jQuery datepicker to recreate the calendar in a PHP file.
This is the code I'm using, and it works good:
$(document).ready(function() {		var dates = $( "#from, #to" ).datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 1,
			onSelect: function( selectedDate ) {
				var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}		
		});
	});


                <form method="post" action="code.php?from=The1stDateIhaveSelect&to=The2ndDateIhaveSelect">
                    FROM:
                    <input type="text" id="from" name="from" value="The1stDateIhaveSelect(how can I put it here???)" />
                    TO:
                    <input type="text" class="two" id="to" name="to" value="The2ndDateIhaveSelect(how can I put it here???)" />
                    
                    <input type="submit" name="Submit">
                </form>




I'm using also a form where I put the dates, but I want to grab the date, store the date in a variable and using a $_GET (something like: http://127.0.0.1/mai...DateIhaveSelect) to pass them to another file and put in another field.

Is it possible? How? I'm crashing my head on this code, but I cannot figure it.

---------- Post added at 01:33 AM ---------- Previous post was at 12:49 AM ----------

Seems funny but I solved by myself.

Just put in the other file the variable from and to.

[SOLVED]

#2
Thevenin

Thevenin

    Learning Programmer

  • Members
  • PipPipPip
  • 58 posts
A little new problem....I wanna send these information throught a PHP form but don't know why the "from" and "to" field (the date) don't arrive, I use this thing:

$name = $_REQUEST["name"];
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$from = $_REQUEST["from"];

$name = stripslashes($name); 
$message = stripslashes($message); 
$subject = stripslashes($subject); 
$from = stripslashes($from); 

$body .= "Arrival: " . trim(stripslashes($_POST["arrival"])) . "\n";
$body .= "Departure: " . trim(stripslashes($_POST["departure"])) . "\n";
$body .= "Name: " . trim(stripslashes($_POST["name"])) . "\n";




I have modified the above code (the one in the first post) like this one:

$(document).ready(function() {
        var dates = $( '#arrival, #departure' ).datepicker({
            defaultDate: '+1w',
            changeMonth: true,
            numberOfMonths: 1,
            onSelect: function( selectedDate ) {
                var option = this.id == 'arrival' ? 'minDate' : 'maxDate',
                    instance = $( this ).data( 'datepicker' ),
                    date = $.datepicker.parseDate(
                        instance.settings.dateFormat ||
                        $.datepicker._defaults.dateFormat,
                        selectedDate, instance.settings );
                dates.not( this ).datepicker( 'option', option, date );
            }        
        });
    });





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users