Merging Two Textfields And Preview It In Third Textfield Automatically When Keyup Trigers

HI

BELOW is my code. when you type doc_name and Prefix and press tab key it should merge doc_name and Prefix textfields and display it in Preview field. Please help me.

<div class="row">

	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'Doc_name'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model,'Doc_name',array('size'=&gt;50,'maxlength'=&gt;50)); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'Doc_name'); ?&gt;


&lt;/div&gt;





&lt;div class=&quot;row&quot;&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'Prefix'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model,'Prefix',array('size'=&gt;10,'maxlength'=&gt;10));?&gt;


        	&lt;?php echo &#036;form-&gt;error(&#036;model,'Prefix'); ?&gt;


&lt;/div&gt;

<?php echo $form->labelEx($model,‘Preview’); ?>

     &lt;?php echo &#036;form-&gt;textField(&#036;model,'Preview',array('size'=&gt;60,'maxlength'=&gt;90)); ?&gt;


        


	&lt;?php echo &#036;form-&gt;error(&#036;model,'Preview'); ?&gt;


&lt;/div&gt;

Welcome iqbalbaba,

I dont’ have time to show you a complete example but I hope I can guide you into the right direction

[list=1][][size=“2”]Add ID’s to the three textfields => [/size]$htmlOptions[]Define a keyup jQuery handler and use the defined ID’s as selectors => jQuery Event - keyup or use jQuery’s event bubbling

  • Inside the event handler:[list]
  • get values from the doc_name and prefix textfield via val() function and ID selectors and/or use this
  • concatenate the values and set it also via val() function

[/list][/list]

This are the basic task you have to do. If you have problems you are welcome to ask specific questions here again.

Hi Kokomo,

Thank you for your reply.

I am new to Yii and i started it 4 days before. Please guide me and if u know the coding please post me.

It will be helpful to me.

I appreciate your reply.

The tasks to achieve your goal contains nothing special about yii knowledge. It’s just javascript with help of jQuery.

If you have problems doing it I would strongly suggest you to look at some php/javascript/jQuery tutorials and learn the basics before you go further with yii.

Yii is a framework that assists you in doing tasks faster and in a more efficient way but can’t help you if you miss basic coding knowledge.