How To Get A Dynamic Textfield Id In Js

Hi there.

I have a textField with the id that depends on the some value dynamically.

But for some code the id is inside js so I can’t find the solution for passing id to js. (I’ve done a searching through google with no luck)

Here is the code:




<?php

echo CHtml::textField('avaiable_since','', array('id'=>'avaiable_sinceId'.$driverArrayId[$j])); 			

            			

echo CHtml::ajaxSubmitButton (

	'Add',

	Yii::app()->createUrl('session/update_driver_avai'),

	array(

		'type'=>'POST',

		'data' => array('id' => $driverArrayId[$j] , 'avaiable_since' => 'js:document.getElementById("avaiable_sinceId").value' )

	         )			            

	); 

 ?>



avaiable_sinceId should be the same id as ‘avaiable_sinceId’.$driverArrayId[$j}

so we have to concatenate avaiable_sinceId and the value of $driverArrayId[$j]. How could I do that?

Thanks in advanced!

Also concatenate field value for id in JS, like:




<?php


echo CHtml::textField('avaiable_since','', array('id'=>'avaiable_sinceId'.$driverArrayId[$j]));                 		


echo CHtml::ajaxSubmitButton (

  'Add',

  Yii::app()->createUrl('session/update_driver_avai'),

  array(

    'type' => 'POST',

    'data' => array(

      'id' => $driverArrayId[$j],

      'available_since' => "js:document.getElementById('available_sinceId" . $driverArrayId[$j] . "').value",

    ),

  ),

);


?>




Well, everything seems ok but the id and avaiable_since are not passed to update_driver_avai!?!?!

Somebody help me!!!

Test from firebug whether the id’s are being generated or not.Also check if


$driverArrayId[$j]

contains value or not.

The id is passed well. The ‘available_sinceId’.$driverArrayId[$j] is generated as well but not passed.