Yii Framework Forum: [solved] CJuiAutocomplete ga bisa di clone kah? - Yii Framework Forum

Jump to content

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

[solved] CJuiAutocomplete ga bisa di clone kah? Rate Topic: -----

#1 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 18 January 2011 - 03:43 AM

helo..
saya perlu membuat field dgn autocomplete yang bisa bertambah (dicloning)

saya coba menggunakan CJuiAutocomplete dan jquery tuk menclone

ini kode di _form.php:

<p class="clone">
                <?php 
                $this->widget('zii.widgets.jui.CJuiAutoComplete',array(
    'name'=>'product_number',
        'model'=>$model2,
        'attribute'=>'product_number[]',
        'value'=>'',
    'sourceUrl'=>$this->createUrl('productDelivery/autocomplete'),
    
    'options'=>array(
        'minLength'=>'2',
    ),
    'htmlOptions'=>array(
        'style'=>'height:16px;'
    ),
));

?>
</p>
<p><a href="#" class="add" rel=".clone">Add More</a></p>


CJuiAutocomplete nya berjalan dengan baik,jika saya tidak menekan add-more / meng-clonenya.
jika saya menekan add-more,fieldnya muncul namun autocompletenya ga jalan
saya rasa masalah bukan di controllernya.
apakah CJuiAutocomplete memang tdk dapat diclone.?
tolong share yah yang bisa

thanks..
take it or leave it
0

#2 User is offline   ibiz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 26-November 10
  • Location:Indonesia

Posted 18 January 2011 - 11:10 PM

ane nyoba di view 2 widget untuk 1 attribut yg sama ga bisa, yii menggenerate html kode yg tidak identik:
<div class="row">
<label for="Post_tags">Tags</label>
<input size="50" id="Post_tags" name="Post[tags]" type="text" autocomplete="off" class="ac_input"/>
<p class="hint">Please separate different tags with commas.</p>
</div>
<div class="row">
<label for="Post_tags">Tags</label>
<input size="50" id="Post_tags" name="Post[tags]" type="text"/>
<p class="hint">Please separate different tags with commas.</p>
</div>

klo 2 widget utk 2 attribut yg berbeda sih bisa :).

btw kenapa agan pake clone di client side ga pake opsi: 'multiple'=>true, ??
WYSIWYG
(What Yii Serve is What You Get)
0

#3 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 19 January 2011 - 01:15 AM

soalnya klo gue ga tetap,jadi terserah si user mau isi brpa..
jdi gni struktru db nya

productDelivery:
id
tgl
no_invoice
no_order


productDeliveryDetail:
id
productnum
productdesc
quantity
productDelivery_id(FK)

gitu gan..
tergantung si user brapa itemkah yang ditambahin ke detailnya
nah yang mau dipasang CJuiAutoComplete itu yang productnum...
productdesc tar tergantung pilihan dari Cjuinya..

btw gan,'multiple'=> true itu untuk apaan gan?
coba gan jelaskan sedikit kali aja ternyata pake itu bisa,maav ni sebelumnya soalnya ane blom ngerti2 banget yii
jadi ga tau ada 'multiple'=>true
take it or leave it
0

#4 User is offline   ibiz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 26-November 10
  • Location:Indonesia

Posted 19 January 2011 - 02:38 AM

itu fitur di CAutocomplete sih, misal:
		<?php $this->widget('CAutoComplete', array(
			'model'=>$model,
			'attribute'=>'barang',
			'multiple'=>true,
			'htmlOptions'=>array('size'=>50),
		)); ?>

ada form yg mengambil list nama barang dari attribut model kayak gitu, klo dikasi opsi 'multiple'=>true,
dia bisa melakukan beberapa kali autocomplete nama barangnya, so nanti field tersebut keliatan seperti ini :
__________________
|sepeda, baju, sepatu|
| OK |

sebagaimana penjelasan didokumentasinya:
multiple | boolean | whether to allow more than one autocompleted-value to enter. | CAutoComplete |
WYSIWYG
(What Yii Serve is What You Get)
0

#5 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 19 January 2011 - 09:44 PM

View Postibiz4, on 19 January 2011 - 02:38 AM, said:

itu fitur di CAutocomplete sih, misal:
		<?php $this->widget('CAutoComplete', array(
			'model'=>$model,
			'attribute'=>'barang',
			'multiple'=>true,
			'htmlOptions'=>array('size'=>50),
		)); ?>

ada form yg mengambil list nama barang dari attribut model kayak gitu, klo dikasi opsi 'multiple'=>true,
dia bisa melakukan beberapa kali autocomplete nama barangnya, so nanti field tersebut keliatan seperti ini :
__________________
|sepeda, baju, sepatu|
| OK |

sebagaimana penjelasan didokumentasinya:
multiple | boolean | whether to allow more than one autocompleted-value to enter. | CAutoComplete |


tapi pas dipake di framework versi 1.1.5 kok ga mau ya CAutoComplete?
pake framework brapa bang?
take it or leave it
0

#6 User is offline   ibiz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 26-November 10
  • Location:Indonesia

Posted 20 January 2011 - 02:47 AM

sama kok, ane pake versi 1.1.5
WYSIWYG
(What Yii Serve is What You Get)
0

#7 User is offline   ibiz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 26-November 10
  • Location:Indonesia

Posted 20 January 2011 - 05:22 AM

coba agan pelajari contoh blog disini:
http://www.yiiframew...rbac_1.1.1.zip/
tepatnya pada file
yii_blog_demo-srbac_1.1.1.zip\blog\protected\views\post\_form.php
WYSIWYG
(What Yii Serve is What You Get)
0

#8 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 27 January 2011 - 10:48 PM

wes udah berhasil gan..
jadi pas di clone id nya di ++ aja.
udah deh,jadinya field kita bisa di clone sebanyak yang kita mau dan autocompletenya tetap jalan,heuhueheuhue
kalo udah tau mah kyknya gampang ya
take it or leave it
0

#9 User is offline   ibiz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 151
  • Joined: 26-November 10
  • Location:Indonesia

Posted 28 January 2011 - 02:56 AM

congrats bro, jgn lupa tritnya rename ditambahin kata solved
WYSIWYG
(What Yii Serve is What You Get)
0

#10 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 221
  • Joined: 26-September 09

Posted 11 August 2011 - 11:34 PM

View Postressaince, on 27 January 2011 - 10:48 PM, said:

wes udah berhasil gan..
jadi pas di clone id nya di ++ aja.
udah deh,jadinya field kita bisa di clone sebanyak yang kita mau dan autocompletenya tetap jalan,heuhueheuhue
kalo udah tau mah kyknya gampang ya


Halo ressaince,

bisa share caranya? kok punya saya g bisa nampilin autocompletenya y??

Thanks a lot.
0

#11 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 17 August 2011 - 12:31 AM

gan bikin autocompletenya dijadiin function di javascriptnya..trus tiap di clone dipanggil fungsi tersebut jadi yang diclone bisa juga
take it or leave it
0

#12 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 221
  • Joined: 26-September 09

Posted 17 August 2011 - 09:53 PM

View Postressaince, on 17 August 2011 - 12:31 AM, said:

gan bikin autocompletenya dijadiin function di javascriptnya..trus tiap di clone dipanggil fungsi tersebut jadi yang diclone bisa juga


jadi bikinnya bukan pake yii CJuiAutocomplete tapi langsung jQuery.Autocomplete?

Boleh kasih contohnya?

Thanks.
0

#13 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 18 August 2011 - 04:25 AM

yup..jgn pake Cjui

tar deh bro..gw lagi ga depan leptop
take it or leave it
0

#14 User is offline   kodok 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 03-May 11

Posted 11 September 2011 - 09:53 PM

bos boleh tolong dishare ga contoh scriptnya, lagi butuh untuk kasus yang sama.. thanks
0

#15 User is offline   somploc 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 16-November 11

Posted 06 March 2013 - 05:12 AM

gan boleh gk di share, terima kasih :D
0

#16 User is offline   Nasirudin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 01-March 13
  • Location:Cikarang

Posted 31 May 2013 - 02:04 AM

gan ane juga punya kasus yang sama neh tapi yum selesaiĀ² boleh minta source codenya!! :) :)
0

#17 User is offline   dapitpio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 22-May 13

Posted 31 May 2013 - 02:22 AM

View Postressaince, on 27 January 2011 - 10:48 PM, said:

wes udah berhasil gan..
jadi pas di clone id nya di ++ aja.
udah deh,jadinya field kita bisa di clone sebanyak yang kita mau dan autocompletenya tetap jalan,heuhueheuhue
kalo udah tau mah kyknya gampang ya


bisa dishare caranya gan, perlu banget ni :)
0

#18 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 18 June 2013 - 09:06 AM

<?php
$this->breadcrumbs=array(
	'Product Deliveries'=>array('index'),
	'Create',
);
	//Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/javascript/jquery-1.4.2.min.js',CClientScript::POS_HEAD);
	Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/javascript/jquery-ui-1.8.4.custom.min.js',CClientScript::POS_HEAD);
	Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/javascript/jquery.autocomplete.js',CClientScript::POS_HEAD);
	Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/javascript/ui.dropdownchecklist-1.1-min.js',CClientScript::POS_HEAD);
	Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/javascript/calendar.js',CClientScript::POS_HEAD);
	Yii::app()->clientScript->registerCssFile(Yii::app()->request->baseUrl.'/css/cwcalendar.css', 'screen');
	Yii::app()->clientScript->registerCssFile(Yii::app()->request->baseUrl.'/css/jquery.autocomplete.css', 'screen');
	Yii::app()->clientScript->registerCssFile(Yii::app()->request->baseUrl.'/css/jquery-ui-1.8.4.custom.css', 'screen');
	Yii::app()->clientScript->registerCssFile(Yii::app()->request->baseUrl.'/css/ui.dropdownchecklist.themeroller.css', 'screen');
?>
<br/>
<h1>Pembuatan Product Delivery /S.P.B </h1>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'product-delivery-form',
	'enableAjaxValidation'=>false,
)); ?>
	
	<p class="note">Fields with <span class="required">*</span> are required.</p>
	
	<?php echo $form->errorSummary(array($model,$model2)); ?>
	<table style="width:550px">
	<tr>
		<td><?php echo $form->labelEx($model,'delivery_order_no'); ?></td>
		<td><?php echo $form->textField($model,'delivery_order_no',array("value"=>$model->getValue(),'maxlength'=>50,'class'=>'eek','onchange'=>'NoWhiteSpace(this);check(this,1);')); ?>
		<?php echo $form->error($model,'delivery_order_no'); ?></td>
	</tr>
	
	<tr>
		<td><?php echo $form->labelEx($model,'order_cust_no'); ?></td>
		<td><?php echo $form->textField($model,'order_cust_no',array("class"=>"sono",'maxlength'=>50,'onchange'=>'NoWhiteSpace(this);check(this,2);')); ?>
		<?php echo $form->error($model,'order_cust_no'); ?></td>
	</tr>

	<tr>
		<td><?php echo $form->labelEx($model,'invoice_no'); ?></td>
		<td><?php echo $form->textField($model,'invoice_no',array("class"=>"invno",'size'=>20,'maxlength'=>50,'onchange'=>'NoWhiteSpace(this);check(this,3);')); ?>
		<?php echo $form->error($model,'invoice_no'); ?></td>
	</tr>

	<tr>
		<td><?php echo $form->labelEx($model,'delivery_date'); ?></td>
		<td><?php echo $form->textField($model,'delivery_date',array("value"=>date("Y-m-d"),'class'=>'meong')); ?>
		<?php echo $form->error($model,'delivery_date'); ?></td>
	</tr>
	<tr>
		<td><?php echo $form->labelEx($model,'shipping_date'); ?></td>
		<td><?php echo $form->textField($model,'shipping_date',array("value"=>date("Y-m-d"),'class'=>'garong')); ?>
		<?php echo $form->error($model,'shipping_date'); ?></td>
		</tr>
	<tr>
		<td><?php echo $form->labelEx($model,'order_cust_date'); ?></td>
		<td><?php echo $form->textField($model,'order_cust_date',array("id"=>"date1","onClick"=>'fPopCalendar("date1");')); ?>
		<img src="<?php echo Yii::app()->request->baseUrl; ?>/images/calendar.png" id='gambar1' onclick='fPopCalendar("date1")'/> 
		<?php echo $form->error($model,'order_cust_date'); ?></td>
	</tr>

	<tr>
		<td><?php echo $form->labelEx($model,'invoice_date'); ?></td>
		<td><?php echo $form->textField($model,'invoice_date',array("id"=>"date2","onClick"=>'fPopCalendar("date2");')); ?>
		<img src="<?php echo Yii::app()->request->baseUrl; ?>/images/calendar.png" id='gambar2' onclick='fPopCalendar("date2")'/>
		
		<?php echo $form->error($model,'invoice_date'); ?></td>
		
	</tr>

	<tr>
		<td><?php echo $form->labelEx($model,'customer_id'); ?></td>
		<td><?php echo $form->dropDownList($model,'customer_id', Customer::model()->getCustomerDropDownList(),array("class"=>"ook")); ?> 
		<?php echo $form->error($model,'customer_id'); ?></td>
	</tr>

	<tr>
		<td><?php echo $form->labelEx($model,'forwarding_agent'); ?></td>
		<td><?php echo $form->textField($model,'forwarding_agent',array('size'=>20,'maxlength'=>128,'class'=>'sukasuka')); ?>
		<?php echo $form->error($model,'forwarding_agent'); ?></td>
	</tr>
	<tr>
		<td><?php echo $form->labelEx($model,'category'); ?></td>
		<td><?php echo $form->dropDownList($model,'category',$model->getCat(),array('class'=>'cie')); ?>
		<?php echo $form->error($model,'category'); ?></td>
	</tr>
	<tr>
		<td><?php echo $form->labelEx($model,'keterangan'); ?></td>
		<td><?php echo $form->textField($model,'keterangan',array('size'=>30,'maxlength'=>250)); ?>
		<?php echo $form->error($model,'keterangan'); ?></td>
	</tr>
	</table>
	
	<?php// echo $form->hiddenField($model,'last_update',array('value'=>date('Y-m-d h:i:s'))); ?>
	<div class="row">
	
	<table width="100%">
	<tr>
	<th >Product Number<span class="required">*</span></th>
	<th >Product Description<span class="required">*</span></th>
	<th >Quantity<span class="required">*</span></th>
	<th >Serial Number</th>
	<th >Chasis Number</th>
	<th >Kelengkapan</th>
	<th >Site</th>
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	</tr>
	</table>
	
</div>
	<fieldset id="participantsField">
	<div class="participant">

		<input class="user_selector" name="ProductDeliveryDetail[product_number][]" onchange="javascript:this.value=this.value.toUpperCase();NoWhiteSpace(this);" value="" size="16" id="num0"/>
		<?php //echo $form->error($model2,'product_number'); ?>
		<?php echo $form->textField($model2,'product_desc[]',array('size'=>'16','id'=>'desc0')); ?>
		<?php //echo $form->error($model2,'product_desc'); ?>
		<?php echo $form->textField($model2,'quantity[]',array('size'=>'16','value'=>'1','disabled'=>true)); ?>
		
		<?php echo $form->textField($model2,'serial_number[]',array('size'=>'16','id'=>'ser0','onChange'=>'checkSerial(this,1);')); ?>
		<?php //echo $form->error($model3,'serial_number'); ?>
		<?php echo $form->textField($model2,'chasis_number[]',array('size'=>'16','id'=>'cha0','onChange'=>'checkSerial(this,2);')); ?>
		<input type="hidden" name="ProductDeliveryDetail[kelengkapan][]" class="benge0"/>
		<select class="s10" size="10">
		<?php 
			foreach(Kelengkapan::model()->findAll() as $row1)
			{
			echo '<option value="'.$row1["id"].'">'.$row1["kelengkapan"].'</option>';	
			}
				?>
	        </select>
			<select id="ahh0" name="ProductDeliveryDetail[cust_loc_id][]">
			<option value=""  style="width:60px"> </option>
			</select>
		
		</div>
		<br />
		</fieldset>
		<p class="hide_element" id="template">
		
		<input class="user_selector" name="ProductDeliveryDetail[product_number][]" onchange="javascript:this.value=this.value.toUpperCase();NoWhiteSpace(this);" value="" size="16" id="num"/>
		<?php //echo $form->error($model2,'product_number'); ?>
		<?php echo $form->textField($model2,'product_desc[]',array('size'=>16,'id'=>'desc')); ?>
		<?php //echo $form->error($model2,'product_desc'); ?>
		<?php echo $form->textField($model2,'quantity[]',array('size'=>16,'value'=>'1','disabled'=>true)); ?>
		
		<?php echo $form->textField($model2,'serial_number[]',array('size'=>'16','id'=>'ser','onChange'=>'checkSerial(this,1);')); ?>
		<?php //echo $form->error($model3,'serial_number'); ?>
		<?php echo $form->textField($model2,'chasis_number[]',array('size'=>'16','id'=>'cha','onChange'=>'checkSerial(this,2);')); ?>
		<?php //echo $form->error($model3,'chasis_number'); ?>
		<input type="hidden" name="ProductDeliveryDetail[kelengkapan][]" class="benge"/>
		<?php //echo $form->hiddenField($model3,'kelengkapan[]',array('class'=>'benge')); ?>
		
		<select class="s1" size="10">
		<?php 
			foreach(Kelengkapan::model()->findAll() as $row1)
			{
			echo '<option value="'.$row1["id"].'">'.$row1["kelengkapan"].'</option>';	
				}
				?>
	        </select>
			<select id="ahh" name="ProductDeliveryDetail[cust_loc_id][]">
			<option value=""  style="width:60px;"> </option>
			</select>
		</p>
		
		
	
	
	<?php //<p><a href="#" class="add" rel=".clone">Add More</a></p>?>
	<p><input type="button" id="addParticipant" value="Tambah Pesanan"></p>
	<div class="row buttons">
		<?php //echo CHtml::submitButton($model->isNewRecord ? 'Simpan' : 'Save'); ?>
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Simpan' : 'Save',array('class'=>'super','onClick'=>'if(checkcok()==false)return false;$("#template").remove();')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
<script type="text/javascript">
var current= 0;

	function setAutocomplete()
    {
	
	 $(".user_selector").autocomplete('<?php echo Yii::app()->request->baseUrl; ?>/index.php/productDelivery/autocomplete', 
            {
				
			
			selectFirst: false,
			width: 150,
			
 
  			
			}
        );
		
		
		$(".user_selector").result(function(event, data, formatted) {
		if (data){
			var oke=data[0].substring(2,4);
			oke=data[1]+" "+oke;
			$(this).next().val(oke);
			}
			});

		
		
	
 
		
		}
	var removeLink = ' <a class="remove" href="#" onclick="$(this).parent().slideUp(function(){ $(this).remove() });return false;">X</a>';
	//var removeLink = ' <a class=\"remove\" href=\"#\" onclick=\"$()\">X</a>';

        function bumped(data){
		
		$(".s1"+data).dropdownchecklist( { forceMultiple: true,onComplete: function(selector) {
			  	var values = "";
			  	for( i=0; i < selector.options.length; i++ ) {
			    	if (selector.options[i].selected && (selector.options[i].value != "")) {
			      		if ( values != "" ) values += ",";
			      		values +=selector.options[i].value;
			    	}
			  	}
			
			$(".benge"+data).val(values);
            } });
		
		}
    
        
//	var current= 0;
	function checkNull()
	{var e;
	$(".participant").children(":input").each(function(i) {
	var $currentElem= $(this);
	e=$currentElem.val();
	if(e=="")
	{
	alert('isilah');
	return false;
	
	}
	
	}
	
	);
	
	}
	function checkSerial(ele,tipe)
	{
	var data=ele.value;
	if(data!="")
		{
	$.ajax({
	url:'<?php echo Yii::app()->request->baseUrl; ?>/index.php/productDelivery/checkSerial',
	data: "do="+data+"&tipe="+tipe,
	cache: false,
	success: function(msg){
	if(msg=='sukses'){
	alert('Nomor Tersebut sudah Ada');
	ele.value="";
	}
	
	}
	});
		}
	
	}
	
	function checkcok()
	{
	var eek=$(".eek").val();
	var meong=$(".meong").val();
	var garong=$(".garong").val();
	var date1=$("#date1").val();
	var ook=$(".ook").val();
	var sukasuka=$(".sukasuka").val();
	var cie=$(".cie").val();
	for(c=0;c<current+1;c++)
	{
	var num=$("#num"+c).val();
	var desc=$("#desc"+c).val();
	var ser=$("#ser"+c).val();
	var cha=$("#cha"+c).val();
	if(num==""||desc==""||eek==""||meong==""||garong==""||date1==""||ook==""||sukasuka==""||cie=="")
	{
	alert('Data dengan * harus Diisi');
	return false;
	}
	if(ser!=""||cha!="")
		{
		for(o=c+1;o<current+1;o++)
		{
		var num1=$("#ser"+o).val();
		var ha=$("#cha"+o).val();
		if(num1!=""&&num1==ser||ha!=""&&ha==cha)
		{
		alert('Nomor Serial atau Nomor Chasis Tidak Boleh Sama');
		return false;
		}
		
		}
		}
	}
	}
    var addParticipantFields = function() 
    {
		if(checkcok()==false)return false;
        current++;
        $newParticipant = $("#template").clone();
        $newParticipant.removeAttr("id");
        $newParticipant.removeAttr("class");
		$newParticipant.attr("class","participant");
		
        $newParticipant.children(":input").each(function(i) {
            var $currentElem= $(this);
            $currentElem.attr("class",$currentElem.attr("class")+current);
			$currentElem.attr("id",$currentElem.attr("id")+current);
			 
			
        });
		
		//$newParticipant.children(\"select\").each(function(i){
		//});
		
        $newParticipant.appendTo("#participantsField");
		 $newParticipant.append(removeLink);
        setAutocomplete();
		bumped(current);
		bush(current,bos);
    }
	function check(data,tipe)
	{
	//var val=$('.eek').val();
	var val=data.value;
	$.ajax({
	url:'<?php echo Yii::app()->request->baseUrl; ?>/index.php/productDelivery/check',
	data: "do="+val+"&tipe="+tipe,
	cache: false,
	success: function(msg){
	if(msg=='sukses'){
	alert('Nomor Tersebut sudah Ada');
	switch(tipe)
		{
		case 1:data.value=dono;break;
		case 2:data.value=sono;break;
		case 3:data.value=invno;break;
		default:data.value="";break;
		}
	}
	
	}
	});
	
	}
	
	
	var bos;
	var getLoc=function()
	{
	
	var val=$('.ook').val();
	$.ajax({
	url:'<?php echo Yii::app()->request->baseUrl; ?>/index.php/productDelivery/getloc',
	data: "id="+val,
	cache: false,
	success: function(msg){
	data=msg.split("|");
	var tes='<option value="0" style="width:auto;">Belum Tahu</option>';
	for(i=0;i<data.length;i=i+2)
	{
	if(data[i+1]!=null)
	tes+='<option value="'+data[i]+'" style="width:auto;">'+data[i+1]+'</option>';
	
	}
	bos=tes;
	for(i=0;i<=current;i++)
	{
	bush(i,tes);
	}
	}
	});
	}
	function bush(data,tes)
	{
	$("#ahh"+data).children("option").each(function(i){
	 var $currentElem= $(this);
	 $(this).remove();
	});
	$("#ahh"+data).append(tes);
	}
	function NoWhiteSpace(data)
	{
	var val=data.value;
	data.value=val.replace(/\s+|\s+$/g,'');
	}
	var dono="";
	var sono="";
	var invno="";
    $(document).ready(function() {
        setAutocomplete();
		bumped(current);
        $("#addParticipant").live("click", addParticipantFields);
		//$('.eek').live('change', check);
		dono=$('.eek').val();
		sono=$('.sono').val();
		invno=$('.invno').val();
		$('.ook').live('change', getLoc);
		//$('.super').live('change', checkcok());
		var isi=$('.ook').val();
		if(isi!=null){getLoc();}
    });
</script>



Mudah sekali, setiap klik, setautocompletenya....
ini main di file viewnya doang,
untuk autocompletenya udah tau kan cara proses nya di controller?

silahkan dipelajari,
yang di clone tu di div class participant.
sorry code i copas semua ya, bukan ga niat ngajarin, tapi cape gan plg kantor

sory bro bro semuam, dah lama ga buka.
jangan ragu kalau nanya mail ke bob.hartanto@gmail.com, tp jgn spam ya
take it or leave it
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