Yii Framework Forum: using onblur at a new textfield (out of model) - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

using onblur at a new textfield (out of model) Rate Topic: -----

#1 User is offline   mbaksri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 15-July 11

Posted 20 February 2012 - 09:15 PM

Hi, i wanna ask about onblur function that will be added into a new textfield, which out of the model?
Really need an inspiration
Thanks :lol:
0

#2 User is offline   rookie84 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 114
  • Joined: 16-November 11

Posted 21 February 2012 - 01:24 AM

Will this inspire you? :P Lol

<?php echo CHtml::activeTextField($model, 'content', array('class' => 'content')); ?>

<?php
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerScript('effect', "
$(document).ready(function() {
$('input.content').blur(function() {
alert($(this).val())
});
});
", CClientScript::POS_END);
?>
0

#3 User is offline   mbaksri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 15-July 11

  Posted 21 February 2012 - 10:52 PM

View Postrookie84, on 21 February 2012 - 01:24 AM, said:

Will this inspire you? :P Lol

<?php echo CHtml::activeTextField($model, 'content', array('class' => 'content')); ?>

<?php
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerScript('effect', "
$(document).ready(function() {
$('input.content').blur(function() {
alert($(this).val())
});
});
", CClientScript::POS_END);
?>


hehe,, thanks for suggestion, rookie84..

actually i want that new textfield is filled by the other attributes in the other model.
here's my code

in Controller


public function actionCekProp ()
	{
		$cekprop=$_GET['cekprop'];
		$sql=master_prop::model()->findAllByAttributes(array('kode_prop'=>$cekprop));
		foreach ($sql as $i)
		{
			echo $i->propinsi;
		}
	}


in _form


<script type='text/javascript' src="<?php echo Yii::app()->request->baseUrl; ?>/css/jquery.js" ></script>

<script type="text/javascript">
		$(document).ready(function(){
			$("#dokumen_kode_prop").blur(function(){
				var cekprop = $("#dokumen_kode_prop").val();
				$.ajax({
					url: "<?php echo Yii::app()->createUrl('dokumen/cekprop')?>",
					data: "cekprop=" + cekprop,
					success: function(data){
						$("#dokumen_prop").html(data);
				}
			});
		});
	});
</script>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'dokumen-form',
	'enableAjaxValidation'=>false,
)); ?>
	
	<?php echo $form->errorSummary($model); ?>
	
	
	<div class="row">
		<?php echo $form->labelEx($model,'kode_prop :'); ?>
		<?php echo $form->textField($model,'kode_prop'); ?>
		<?php echo $form->textField($model,'prop'); ?>
		<?php echo $form->error($model,'kode_prop'); ?>
	</div>
	
<?php $this->endWidget(); ?>

</div><!-- form -->


but actually, it still won't be appeared into $prop.. Thanks so much for yr respon again :lol:
0

#4 User is offline   mbaksri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 15-July 11

Posted 21 February 2012 - 11:16 PM

It's clearly solved. I did a mistake with .html() which should be changed with .val()..
:rolleyes:
0

#5 User is offline   rookie84 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 114
  • Joined: 16-November 11

Posted 21 February 2012 - 11:27 PM

It is difficult to suggest anything when I don't know about the context you are working on. Here's my suggestion anyway:

Try Firebug or anything like that to see if you form is actually send results.
Try success: function(data) { alert(data); } to see you are actually getting the data
Do console.log to see the results in your firebug.
0

#6 User is offline   mbaksri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 15-July 11

Posted 22 February 2012 - 03:27 AM

View Postrookie84, on 21 February 2012 - 11:27 PM, said:

It is difficult to suggest anything when I don't know about the context you are working on. Here's my suggestion anyway:

Try Firebug or anything like that to see if you form is actually send results.
Try success: function(data) { alert(data); } to see you are actually getting the data
Do console.log to see the results in your firebug.



:D , I'm so sorry for making you confuse with my question,, cause I thought i've said my context before my coding.. ^^'v
Thanks for yr suggestion, rookie84
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users