Option : This tag is used to add the options.
Sample Script :
<script>
function fundis()
{
if(but1.value=="Disable")
{
drp1.disable=true
but1.value='Enable'
}
else
{
drp1.disable=false
but1.value='Disable'
}}
function funrmv()
{
var ind=drp1.selectedIndex
drp1.remove(ind)
}
function funchng()
{
txt=prompt("Enter Text")
ind=drp1.selectedIndex
drp1.option[ind].text=txt;
function funadd()
{
txt=prompt("Enter Text")
drp1.lenght=drp1.lenght+1
drp1.option[drp1.lenght-1].text=txt
}
</script>
<select id="drp1">
<option>PHP Notes</option>
<option>HTML Notes</option>
<option>JavaScript Notes</option>
<option>CSS Notes</option>
</select>
<input type="button" id="but1" value="disable" onclick="fundis()">
<input type="button" value="count" onclick="alert(drp1.lenght)">
<input type="button" value="index" onclick="alert(drp1.selectedIndex)">
<input type="button" value="changetext" onclick="funchng()">
<input type="button" value="AddItem" onclick="funadd()">
function fundis()
{
if(but1.value=="Disable")
{
drp1.disable=true
but1.value='Enable'
}
else
{
drp1.disable=false
but1.value='Disable'
}}
function funrmv()
{
var ind=drp1.selectedIndex
drp1.remove(ind)
}
function funchng()
{
txt=prompt("Enter Text")
ind=drp1.selectedIndex
drp1.option[ind].text=txt;
function funadd()
{
txt=prompt("Enter Text")
drp1.lenght=drp1.lenght+1
drp1.option[drp1.lenght-1].text=txt
}
</script>
<select id="drp1">
<option>PHP Notes</option>
<option>HTML Notes</option>
<option>JavaScript Notes</option>
<option>CSS Notes</option>
</select>
<input type="button" id="but1" value="disable" onclick="fundis()">
<input type="button" value="count" onclick="alert(drp1.lenght)">
<input type="button" value="index" onclick="alert(drp1.selectedIndex)">
<input type="button" value="changetext" onclick="funchng()">
<input type="button" value="AddItem" onclick="funadd()">
Sample Script 2 :
<script>
function fun1()
{
itm=prompt("Enter Total Items")
for(i=0; i<itm; i++)
{
txt=prompt("Enter Text")
drp1.lenght=drp1.lenght+1
drp.options=[drp1.lenght-].text=txt
}}
</script>
<selected id="drp1">
<options>PHP</options>
</select>
<input type="button" value="Click" onclick="fun1()">
function fun1()
{
itm=prompt("Enter Total Items")
for(i=0; i<itm; i++)
{
txt=prompt("Enter Text")
drp1.lenght=drp1.lenght+1
drp.options=[drp1.lenght-].text=txt
}}
</script>
<selected id="drp1">
<options>PHP</options>
</select>
<input type="button" value="Click" onclick="fun1()">
Sample Script 3:
<script>
function funexit(val,min,max)
{
if(val.lenght<min || val.lenght>max)
{
document.getElementByid('txtUname').select()
}}
function funlen(val,min,max<type)
{
if(val.lenght<min)
{
document.getElementByid('div1').innerHTML=<type+"shouldbe>"+min+"characters";
}
else if(val.lenght>max)
document.getElementByid('div1').innerHTML=""
}
</script>
<div id="div1" style="color:red">Enter Values</div>
USERNAME:<input type="text" id="txtuname" onkeyup="funlen(this.value,6,20,'use name')"
nblur="funexit(this.value,6,20)">
<br>
Password:<input type="text" id="txtpwd" onkeyup="funlen(this.value,10,30,'password')">
function funexit(val,min,max)
{
if(val.lenght<min || val.lenght>max)
{
document.getElementByid('txtUname').select()
}}
function funlen(val,min,max<type)
{
if(val.lenght<min)
{
document.getElementByid('div1').innerHTML=<type+"shouldbe>"+min+"characters";
}
else if(val.lenght>max)
document.getElementByid('div1').innerHTML=""
}
</script>
<div id="div1" style="color:red">Enter Values</div>
USERNAME:<input type="text" id="txtuname" onkeyup="funlen(this.value,6,20,'use name')"
nblur="funexit(this.value,6,20)">
<br>
Password:<input type="text" id="txtpwd" onkeyup="funlen(this.value,10,30,'password')">
0 comments:
Post a Comment