Friday, March 25, 2011
Suratku Untukmu ( Queue )
Posted by Dendi Prana Yudha in
Kuliah
<html> <head> <title>Penggunaan Queue</title> <script language="javascript"> <!-- var queue = new Array(); function masuk_antrian(data) { queue.unshift(data); } function keluar_antrian() { var yang_keluar_antrian = queue.pop(); if (queue.length == 0) return (yang_keluar_antrian + " -> Queue sudah kosong"); else return yang_keluar_antrian; } function dalam_antrian(list) { list.options.length = 0; for (var i = 0; i < queue.length; i++) { var data = new Option(queue[i]); list.options[list.options.length] = data; } } //--> </script> </head> <body> <font color=#992811>Visualisasi Queue (Antrian)</font> <form> <input type=text name=textSimpan> <input type=button value="Masuk Antrian" onClick = 'masuk_antrian(textSimpan.value); textSimpan.value = ""; dalam_antrian(visualisasi);'> <select name="visualisasi" size=12> <option>Isi antrian.... </select> <br> <input type=text name=textAmbil size=20> <input type=button value="Keluar Antrian" onClick='textAmbil.value = keluar_antrian(); dalam_antrian(visualisasi);'> </form> </body> </html>
0 komentar:
Post a Comment
Tinggalkan Komentar Disini