|
موضوع اسكريپت منوهاي قابل ويرايش
اين اسكريپت به كاربر اجازه مي دهد كه مواردي كه در منوهاي انتخابي
وجود دارد را به دلخواه خود ويرايش كند ضمنا در اين منو مي توانيد
مواردي كه غير قابل ويرايش باشند را نيز اضافه كنيد .
<!-- TWO STEPS TO INSTALL EDITABLE MENU:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document
-->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site: http://www7.ewebcity.com/cyanide7 -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var o = null;
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function beginEditing(menu) {
finish();
if(menu[menu.selectedIndex].value != "read-only") {
o = new Object();
o.editOption = menu[menu.selectedIndex];
o.editOption.old = o.editOption.text;
o.editOption.text = "_";
menu.blur();
window.focus();
document.onkeypress = keyPressHandler;
}
function keyPressHandler(e){
var option = o.editOption;
var keyCode = (isNN) ? e.which : event.keyCode;
if(keyCode == 8 || keyCode == 37)
option.text = option.text.substring(0,option.text.length-2) + "_";
else if (keyCode == 13) {
finish();
} else
option.text = option.text.substring(0,option.text.length-1) +
String.fromCharCode(keyCode) + "_";
status = keyCode;
}
function finish() {
if(o != null) {
option = o.editOption;
if(option.text.length > 1)
option.text = option.text.substring(0,option.text.length-1);
else
option.text = option.old;
document.onkeypress = null;
o = null;
}
}
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document
-->
<BODY>
<center>
<form>
<select onChange="beginEditing(this);" size=7>
<option value="read-only">Select an option to edit it.</option>
<option value="read-only"> ---------------------------- </option>
<option value="last">SurName</option>
<option value="first">FirstName</option>
<option value="email">Email</option>
<option value="add1">Address 1</option>
<option value="add2">Address 2</option>
</select>
</form>
</center>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts
provided<br>
by ostadonline
<!-- Script Size: 2.12 KB -->
|