IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası

IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası (https://www.ircforumlari.net/)
-   HTML/CSS/JavaScript (https://www.ircforumlari.net/html-css-javascript/)
-   -   select kutusuna dinamik olarak ekleme silme yapmak (https://www.ircforumlari.net/html-css-javascript/625426-select-kutusuna-dinamik-olarak-ekleme-silme-yapmak.html)

hAte 10 Ekim 2014 03:59

select kutusuna dinamik olarak ekleme silme yapmak
 
PHP- Kodu:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
style="color: #007700">> <
html>
<
head>
<
script language="JavaScript" type="text/javascript">
<!--
var 
count1 0;
var 
count2 0;

function 
insertOptionBefore(num)
{
var 
elSel document.getElementById('selectX');
if (
elSel.selectedIndex >= 0) {
var 
elOptNew document.createElement('option');
elOptNew.text 'Insert' num;
elOptNew.value 'insert' num;
var 
elOptOld elSel.options[elSel.selectedIndex]; 
try {
elSel.add(elOptNewelOptOld); // standards compliant; doesn't work in IE
}
catch(
ex) {
elSel.add(elOptNewelSel.selectedIndex); // IE only
}
}
}

function 
removeOptionSelected()
{
var 
elSel document.getElementById('selectX');
var 
i;
for (
elSel.length 1i>=0i--) {
if (
elSel.options[i].selected) {
elSel.remove(i);
}
}
}

function 
appendOptionLast(num)
{
var 
elOptNew document.createElement('option');
elOptNew.text 'Append' num;
elOptNew.value 'append' num;
var 
elSel document.getElementById('selectX');

try {
elSel.add(elOptNewnull); // standards compliant; doesn't work in IE
}
catch(
ex) {
elSel.add(elOptNew); // IE only
}
}

function 
removeOptionLast()
{
var 
elSel document.getElementById('selectX');
if (
elSel.length 0)
{
elSel.remove(elSel.length 1);
}
}
//-->
</script>

</head>
<body>
<form>
<input type="button" value="o" onclick="insertOptionBefore(count1++);" />
Insert Before Selected<br />
<input type="button" value="o" onclick="removeOptionSelected();" />
Remove Selected<br />
<select id="selectX" size="10" multiple="multiple">
<option value="original1" selected="selected">Orig1</option>
<option value="original2">Orig2</option>
</select>
<br />
<input type="button" value="o" onclick="appendOptionLast(count2++);" />
Append Last<br />
<input type="button" value="o" onclick="removeOptionLast();" />
Remove Last
</form>

</body>
</html> 



Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 05:08.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO
Copyright ©2004 - 2025 IRCForumlari.Net Sparhawk