Active Textfield Id To Javascript

it’s about the datepicker jquery that use javascript function like this

and a basic html textfield below

in the simpleway, when i click the textfield, it pass the textfield id to the javascript function…

how to implement this in the yii?

since what i have in my file is

i already try to change the javascript function from

$( "#testid" ).datepicker(); to $( "#start_date" ).datepicker();

but it didn’t work…

try ZiiDatePicker.

You have two options:

[list=1]

[*]Use CJuiDatePicker that wraps jQuery’s UI Datepicker

[*]Or with jQuery nested into PHP:


Yii::app()->clientScript->registerScript('yourScript', '

    $("#' . CHtml::activeId($model, 'start_date') . '").datepicker();

');

[/list]

PS: If you inspect the resulting HTML code of your view, you’ll notice that the ID of your start_date field is something like [font=“Courier New”]“ModelName_start_date”[/font]

i will change my question then…

how to convert

to chtml form…

from what i know is something like this

but how about the id?

@bennouna

i’ll try your solution. edit: I forgot to see the PS at the end of your solution… it solve my problem… thx anyway…

@ karasawaz

Think the issue you might be having is the fact that you are using CHtml::activeTextField and not CHtml::TextField, with the activeTextField it will make the Txt Box name and id = ModelName[yourSpecifiedInputName]. where as if you used just the CHtml::TextBox the name and id would be = yourSpecifiedInputName.

you could obviously use the activeTextBox but then you would have to catch the data on the other side a little differently.

hope i understood what you where asking and that this helps a little at least ;)