Beranda > PEMROGRAMAN > TUTORIAL JAVASCRIPT AUTOCOMPLETE COMBOBOX

TUTORIAL JAVASCRIPT AUTOCOMPLETE COMBOBOX

8 Aug, 2009 Tip n Trik, Web

Autocomplete combobox biasanya di temui pada halaman registrasi pada field Negara dan Propinsi. Ketika user memilih sebuah Negara dari combobox negara, maka combobox propinsi akan secara otomatis merefresh isi propinsinya, sesuai nama negara yang dipilihnya.

Berikut tutorial pembuatan autocomplete combo box menggunakan javascript:

Tutorial ini terdiri dari 4 file :

  1. combobox.html
    		<script src="combobox.js"><!--mce:0--></script>
    		<script src="ardi-ajax.js"><!--mce:1--></script>
    <h2>Auto Complete Combobox</h2>
    <select>
    			<option></option>
    			<option value="indonesia">Indonesia</option>
    			<option value="malaysia">Malaysia</option>
    			<option value="singapore">Singapore</option>
    		</select>
  2. combobox.js
    function autoCombobox(value)
    {
    	//Membuat URl yg disisipkan parameter yang dibutuhkan
    	var url="combobox.php"
    	url=url+"?jenis="+value
    	url=url+"&amp;sid="+Math.random()
    
    	ajax = new ardiAjax();
    	ajax.get(url,
    		function(data)
    		{
    		//Memasukkan hasil response ke textBox "comboBoxArea" di file HTML
    		document.getElementById("comboBoxArea").innerHTML=data;
    		}
    	);
    }
  3. combobox.php
     Array("Indonesia prop A", "Indonesia prop B", "Indonesia prop C", "Indonesia prop D"),
    		'malaysia' =&gt; Array("Malaysia prop A", "Malaysia prop B", "Malaysia prop C"),
    		'singapore' =&gt; Array("Singapore prop A", "Singapore prop B" , "Singapore prop C", "Sigapore prop D")
    	);
    
    	$arr;
    	if(isset($_GET['jenis']))
    	{
    		$arr = $data[$_GET['jenis']];
    	}
    ?&gt;
    <select>
    	<option></option>
    </select>
  4. ardi-ajax.js
    function ardiAjax()
    {
    	this.xmlHttp;
    
    	/**
    	 * @param1 : url = Alamat beserta parameter GET yang akan di parsing
    	 * @param2 : successFunc = Fungsi jika success. Penggunaan : successFunc(dataResponse)
    	 */
    	this.get = function(url, successFunc)
    	{
    
    		//Membuat XmlHttpObject
    		this.xmlHttp = this.GetXmlHttpObject();
    		if (this.xmlHttp==null)
    		{
    			alert ("Browser tidak support HTTP Request");
    			return;
    		}
    
    		//fungsi listener
    		this.xmlHttp.onreadystatechange=function()
    		{
    			//Jika requestnya menerima reponse "complete" yg artinya sukses
    			if (this.readyState==4 || this.readyState=="complete")
    			{
    				successFunc(this.responseText);
    			}
    		};
    
    		//mengirim secara get
    		this.xmlHttp.open("GET",url,true);
    		this.xmlHttp.send(null);
    	};
    
    	//Membuat XmlHttpObject untuk berbagai browser
    	this.GetXmlHttpObject = function()
    	{
    		var xmlhttp=null;
    
    		try
    		{
    			// Firefox, Opera 8.0+, Safari
    			xmlhttp=new XMLHttpRequest();
    		}
    		catch (e)
    		{
    			// Internet Explorer
    			try
    			{
    				xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    			}
    			catch (e)
    			{
    				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    			}
    		}
    		return xmlhttp;
    	};
    
    }

Sumber :
KOMUNITAS PELAJAR ILMU KOMPUTER INDONESIA
http://mr-amateur.co.cc

Kategori:PEMROGRAMAN
  1. September 1, 2013 pukul 12:04 am

    This piece of writing will help the internet users for setting
    up new webpage or even a blog from start to end.

  2. September 18, 2013 pukul 8:04 am

    It’s a pity you don’t have a donate button! I’d definitely donate
    to this fantastic blog! I suppose for now i’ll settle for book-marking and adding your RSS feed to my Google account.

    I look forward to brand new updates and will talk about
    this website with my Facebook group. Talk soon!

  3. Februari 19, 2014 pukul 8:30 am

    Hello there! This is my first visit to your blog! We are a team of
    volunteers and starting a new project in a community in the
    same niche. Your blog provided us beneficial information to work on.
    You have done a wonderful job!

  4. Februari 22, 2014 pukul 2:33 pm

    always i used to read smaller articles which as well clear
    their motive, and that is also happening with this article which I am reading now.

  5. Maret 17, 2014 pukul 11:23 pm

    digitalkamera test
    I every time used to read paragraph in news papers but now as I am a user of net thus from now I am using net for
    content, thanks to web. digitalkamera test

  6. Maret 21, 2014 pukul 1:34 pm

    Creature House also had a frightening videogame created according to it soon
    after it premiered. Math must be a vital section of your son or daughter’s
    lifestyle. He then rides his horse and chases down the felony.

  7. Maret 28, 2014 pukul 9:49 pm

    online casino
    Wonderful web site. Plenty of useful information here.
    I’m sending it to several friends ans additionally sharing in delicious.
    And obviously, thanks in your effort! online casino

  8. April 7, 2014 pukul 12:17 pm

    It got a long time to figure out how exactly to operate MySpace also.
    As a way to try this, you should learn to create an attractive Facebook account.
    Chances are they claim the software must be cracked
    by you.

  9. April 7, 2014 pukul 4:11 pm

    Much like all pc assistance your mileage can vary according to the body setup.

  10. April 8, 2014 pukul 7:26 pm

    She may take vegetable and fresh fruit juices which contain important vitamins and minerals.
    All negative traits such as for instance tension, anger and oversleeping have to be given
    up.

  11. April 16, 2014 pukul 4:12 am

    They understand that pickup lines require to be practiced and perfected.
    Just inquire her out currently…she’ll be waiting around for it.

    Trust me on this, you do not want to shed control of your steps when youre flirting with women.

  12. April 16, 2014 pukul 7:12 am

    There are two attributes, however, that are missing from the current Iphone 3.
    Irrespective of whether it will be a glowing review or information on making their products
    exceptional.

  13. April 19, 2014 pukul 3:13 am

    All Apple cellular devices on the list that depend on the operating system
    iOS are affected. Yup, evidently its heading to work
    on the iPad. You can say goodbye to dreary icons when you Jailbreak ipad.

  14. April 23, 2014 pukul 11:40 am

    Reuters has said that the Apple iphone 5 will be released in September.
    I know, I know; Apple doesn’t want you to use
    a stylus, Apple desires you to use your fingers on the Iphone.
    Get a protective display guard for your telephone.

  15. Mei 4, 2014 pukul 6:28 pm

    Just like the godfather 1 or any grand theft auto sport itis a 3rd person perspective, role-play, and shooting.

    Those who love the sport, think it’s great and those who hate it, hate.

  16. Mei 6, 2014 pukul 10:28 am

    3rd party applications have started including duplicate and paste features, but Apple has yet
    to get on board. They would prefer a new phone instead, so it in the end becomes a make a difference of personal
    choice.

  17. Mei 13, 2014 pukul 11:50 pm

    And isn’t it true, the more hidden (while still to be able to write out the drawing) the better?
    It absolutely was fantastic to begin to see the looks on each of their faces.
    Many rooms have a dvd-player or VCR and a Television.

  18. Mei 18, 2014 pukul 12:05 pm

    Howdy! This is kind of off topic but I need some help from an established blog.
    Is it difficult to set up your own blog? I’m not very
    techincal but I can figure things out pretty quick.
    I’m thinking about setting up my own but I’m not sure where to begin. Do
    you have any ideas or suggestions? Thanks

  19. Juli 5, 2014 pukul 8:17 pm

    When someone writes an piece of writing he/she retains the plan of a user in his/her mind that
    how a user can know it. Therefore that’s why this piece of writing is amazing.
    Thanks!

  20. Juli 7, 2014 pukul 8:38 pm

    It’s really a great and helpful piece of info.
    I’m satisfied that you just shared this useful
    information with us. Please stay us up to date like this.
    Thank you for sharing.

  21. Juli 18, 2014 pukul 3:40 am

    Hello Dear, are you actually visiting this website daily, if so after that
    you will definitely get good know-how.

  22. Juli 21, 2014 pukul 9:40 pm

    I’m extremely pleased to uncover this site. I want to to thank you for ones time just for
    this wonderful read!! I definitely really liked every part
    of it and i also have you saved as a favorite
    to see new stuff on your site.

  23. Agustus 5, 2014 pukul 5:44 am

    It’s very straightforward to find out any topic on web as compared to textbooks, as I found this piece of writing at this site.

  24. September 4, 2014 pukul 3:34 am

    Please let me know if you’re looking for a article author for your weblog.
    You have some really good posts and I think I would be a good asset.
    If you ever want to take some of the load off, I’d absolutely love to write
    some articles for your blog in exchange for a link back
    to mine. Please shoot me an e-mail if interested. Many thanks!

  25. September 6, 2014 pukul 11:37 am

    The other day, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a twenty five foot
    drop, just so she can be a youtube sensation. My iPad is now destroyed and she has
    83 views. I know this is totally off topic but I
    had to share it with someone!

  26. September 6, 2014 pukul 12:25 pm

    Hey there! I could have sworn I’ve been to this site before but after browsing through some
    of the post I realized it’s new to me. Nonetheless, I’m definitely
    delighted I found it and I’ll be bookmarking and checking back
    often!

  27. September 7, 2014 pukul 11:20 pm

    My brother recommended I might like this website. He was entirely right.
    This post truly made my day. You cann’t imagine just
    how much time I had spent for this info! Thanks!

  28. September 13, 2014 pukul 3:52 am

    I’m very pleased to discover this web site. I want to to thank you
    for ones time for this particularly fantastic read!! I definitely liked every part of it and i also have you
    saved as a favorite to see new information in your website.

  29. September 19, 2014 pukul 4:53 am

    You need to be a part of a contest for one of the
    finest websites on the internet. I will highly recommend this web site!

  30. September 19, 2014 pukul 8:37 am

    Undeniably believe that which you stated. Your favorite
    justification seemed to be on the net the easiest thing to be aware of.
    I say to you, I certainly get annoyed while people think about worries that they plainly do
    not know about. You managed to hit the nail upon the top
    and defined out the whole thing without having side-effects , people can take a
    signal. Will likely be back to get more. Thanks

  31. September 19, 2014 pukul 8:48 am

    If you are going for best contents like I do, just go to see this site everyday as
    it offers quality contents, thanks

  32. September 20, 2014 pukul 9:59 pm

    Hi there to every , because I am really eager of reading this weblog’s
    post to be updated on a regular basis. It contains good information.

  33. September 26, 2014 pukul 11:12 am

    Great weblog right here! Also your website quite a bit up fast!
    What host are you the usage of? Can I get your affiliate hyperlink on your host?

    I want my site loaded up as fast as yours lol

  34. Oktober 1, 2014 pukul 3:21 pm

    Thanks for sharing your thoughts on articles. Regards

  35. Oktober 9, 2014 pukul 7:20 am

    I always spent my half an hour to read this website’s articles all the time along with a
    cup of coffee.

  36. Oktober 13, 2014 pukul 4:04 am

    Hello there! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly?
    My site looks weird when viewing from my iphone.
    I’m trying to find a template or plugin that might be able to
    resolve this issue. If you have any suggestions, please share.
    With thanks!

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: