Phiên bản đầy đủ: jsB@nk » Biểu mẫu » Lấy dữ liệu của các dropdown
URL: https://www.javascriptbank.com/bitmap-object-script.html
Hiệu ứng sẽ kiểm tra">kiểm tra và lấy dữ liệu trong các trình đơn kéo thả">kéo thả do người dùng chọn.
Phiên bản đầy đủ: jsB@nk » Biểu mẫu » Lấy dữ liệu của các dropdown
URL: https://www.javascriptbank.com/bitmap-object-script.html
<script>// Bitmap/Object Script// Fernando Rios ([email protected])//these will be the bitmask values. they must be powers of 2var ram128=1;var ram256=2;var ram512=4;var cpu1000=64;var cpu2000=128;var cpu3000=256;var hd20=2048;var hd40=4096;var hd80=8192;//====this will be our 'computer' object===function Computer (f){var features=f;//private variable of computer. stores the features/***priviliged methods of Computer. can be accessed from the outside but also has access to private variable 'features'*/this.getFeatures=function(){var ret="";//return string/*this is where the bitmask operations occurit will do a bitwise comparison of the features value with thevalue that were testing against. if the result is equal to the valuewere testing, the value was set. remember to use a bitwise & instead of &&*/if((features & cpu1000) == cpu1000)ret+="CPU: 1Ghz\n";if((features & cpu2000) == cpu2000)ret+="CPU: 2Ghz\n";if((features & cpu3000) == cpu3000)ret+="CPU: 3Ghz\n";if((features & ram128) == ram128)ret+="RAM: 128MB\n";if((features & ram256) == ram256)ret+="RAM: 256MB\n";if((features & ram512) == ram512)ret+="RAM: 512MB\n";if((features & hd20) == hd20)ret+="HD : 20GB\n";if((features & hd40) == hd40)ret+="HD : 40GB\n";if((features & hd80) == hd80)ret+="HD : 80GB\n";return ret;};this.setFeatures=function (feat){this.features=feat};//**}//=========================================</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name="theForm">Select desired features<br>CPU:<select style="width=125" name="cboCPU"><option value=64>1Ghz (1000Mhz)</option><option value=128>2Ghz (2000Mhz)</option><option value=256>3Ghz (3000Mhz)</option></select><br>RAM:<select style="width=125" name="cboRAM"><option value=1>128MB</option><option value=2>256MB</option><option value=4>512MB</option></select><br>HD: <select style="width=125" name="cboHD"><option value=2048>20GB</option><option value=4096>40GB</option><option value=8192>80GB</option></select><br><!--remember to use | (bitwise OR) when setting the bitmask--><input type="button" value="1. set attributes" onclick="Javascript:aComputer=new Computer(cboCPU.options[cboCPU.selectedIndex].value | cboRAM.options[cboRAM.selectedIndex].value | cboHD.options[cboHD.selectedIndex].value);"><input type="button" value="2. get attributes" onclick="Javascript:alert(aComputer.getFeatures());"><br><input type="reset" value="3. Reset"></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->