Passing Variables From Jquery To View

Hi I have created Fullcalendar on which if user clicks on any date am using Jquery to get the date. Below that I’ve form for events which takes Start date and end date and description. Now what i want is

when any one clicks on the Calendar that date should be get from by the Jquery which is already I am getting and the view model below the calendar’s start date should be automatically filled with the clicked date.

So what i should do to achieve this.

I’m new to AJAX/JQuery/JSON and Yii.

Thanks for your time and consideration

You mean to say you are looking for something like date-picker. Am i right ?? :mellow:

Yeah I have date picker already in the form, Now if Anybody clicks on the calendar start date should be filled with the clicked date and End date will be picked by the date picker…Through Jquery i could alert the current date but I don’t know how to send that variable to Start_date’s model.

Are you using Cjuidatepicker or something else.???

And if you are using Cjuidatepicker then i am sure it will do the same as you are expecting.

Yes, I’m using the same… but it is not happening.

I have written the following code to render the date picker.

<?php

echo $form->labelEx($model,‘start_date’);

	&#036;this-&gt;widget('zii.widgets.jui.CJuiDatePicker', array(


	  'model'=&gt;&#036;model,


	  'attribute'=&gt;'start_date',


	  'value'=&gt;&#036;model-&gt;start_date,


	   'options'=&gt;array(


	    'showAnim'=&gt;'fold',


	    'showButtonPanel'=&gt;true,


	    'autoSize'=&gt;true,


	    'dateFormat'=&gt;'dd-mm-yy',


	    'defaultDate'=&gt;&#036;model-&gt;start_date,


	   ),


	));

Please check that code and also confirm that you are not getting any Js error.

And if you are setting value with $model->start_date then $model->start_date should be initialize.But i dont think that you need to use it.So, just go with the code what i have commented above.

I don’t think I am having any Js error And after commenting that line also its running the same way am not getting any error or warning.

To get the clicked date m writing this jquery

$(document).ready(function() {

$(’#calendar’).fullCalendar({

header: {

left: 'prev,next today',


center: 'title',


right: 'month,agendaWeek,agendaDay'

},

editable: true,

selectable:true,

selectHelper : true,

[color="#800080"] dayClick: function(date, allDay, jsEvent, view) {

  //  alert(date.getDate()+&quot;-&quot;+(date.getMonth()+1)+&quot;-&quot;+date.getFullYear())





selectedDate=date.getDate()+&quot;-&quot;+(date.getMonth()+1)+&quot;-&quot;+date.getFullYear();

alert(selectedDate);[/color]

&#036;(&quot;#mydialog&quot;).dialog(&quot;open&quot;); return false;

//window.showModalDialog("<?php echo Yii::app()->createUrl("events/create");?>");

},

eventClick: function(){

  alert(&quot;EVENT CLICKED&quot;);

},

Are you trying to open a form into a Dialog box.??

Why are you writing that custom jquery code.

Since it is a default behavior of Cjuidatepicker when you pick a date then it will automatically field in a text box.

This error is looked so wired to me.

Oh i got it…You understood my problem in other way, I am using Fullcalendar

http://www.yiiframework.com/extension/fullcalendar/

and when i click on the date it should scroll down to my form which is below to that calendar and the start date of datepicker should automatically filled with the clicked date…

How to attach the snapshot I was searching from long…else would have showed you the snapshot…

hope my question is clear now…

so I have one calendar below that one form with 2 textboxes which are Datepicker.


How to attach the snapshot I was searching from long..else would have showed you the snapshot..

When you post a comment there is a file upload selector there.So you can upload attachments there.

And i will suggest you to go with Cjuidatepicker.it has a same possibilities as you are expecting.