Friday, 31 August 2012

while | if | dropdownlist in javascript

while | if | dropdownlist in javascript
while | if | dropdownlist in javascript
        int i = 0;
        int indx = drpdwn.SelectedIndex;
        int var = 3;
        while (i <= var)
        {
            if (i == indx)
            {
              //  lbl.Text = "you have selected" + indx;
                one.Text =Convert.ToString(indx * 8);
                break;
            }
            else
            {
                i++;
            }
        }

 <table>
    <tr><td>
    <asp:DropDownList ID="drpdwn" runat="server" AutoPostBack="True"
            ontextchanged="drpdwn_TextChanged">
    <asp:ListItem Value="1">Java Programming</asp:ListItem>
    <asp:ListItem Value="2">C Programming</asp:ListItem>
    <asp:ListItem Value="3">Asp Programming</asp:ListItem>
    <asp:ListItem Value="4">c++ Programming</asp:ListItem>
    </asp:DropDownList>
    </td></tr>
    <tr><td>
    <asp:Label runat="server" ID="lbl"></asp:Label>
   
    </td></tr>
    </table>

Javascript | div | hide show | button with source code

Javascript | div | hide show | button with source code
javascript | div | hide show | button with source code
<script>
function funshow()
{
if(document.getElementById("but1").value=="show")
{
document.getElementById('div1').style.visibility="visible"
document.getElementById("but1").value="hide"
}
else
{
document.getElementById('div1').style.visibility="hidden"
document.getElementById("but1").value="show"
}
}
</script>
<body>
<input type="button" value="show" id="but1" onclick="funshow()">
<div id='div1'style="visibility:hidden">
<table bgcolor="lightblue">
<tr><td>
Usename</td>
<td><input type="text"></td></tr>
<tr><td>
Password</td>
<td><input type="text"></td></tr>
<tr><td><input type="button" value="click">
</td></tr>
</table>
</div>
</body>

hide show div | javascript | hide show javascript with code

hide show div | javascript | hide show javascript with code
<script>
function funshow()
{
document.getElementById('div1').style.visibility="visible"
}
function funhide()
{
document.getElementById('div1').style.visibility="hidden"
}
</script>
<body>
<input type="button" value="show" id="butshow" onclick="funshow()">
<input type="button" value="hide" id="buthide" onclick="funhide()">
<div id='div1'style="visibility:hidden">
<table bgcolor="lightblue">
<tr><td>
Usename</td>
<td><input type="text"></td></tr>
<tr><td>
Password</td>
<td><input type="text"></td></tr>
<tr><td><input type="button" value="click">
</td></tr>
</table>
</div>
</body>

javascript set time | javascript date set time

 javascript set time |   javascript date set time


current time is






<script>
function javascriptdatesettime()
{
var d=new Date();
var x=d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()
document.getElementById('div1').innerHTML=x
setTimeout("javascriptdatesettime()",100)
}
</script>
<body>
<div id="div1" style="color:red;font-size:30;font-family:verdana">
current time is
</div>
<input type="button" value="javascript date set time" onclick="javascriptdatesettime()">
</body>


javascript | alert | getHours| getMinutes | getYear | getMonth | getTime

javascript | alert | getHours| getMinutes | getYear | getMonth | getTime




<script>
function checkdate()
{
var d=new Date();
alert("hours:"+d.getHours());
alert("minutes:"+d.getMinutes());
alert("year:"+d.getYear());
alert("month:"+d.getMonth());
alert("date:"+d.getDate());
alert("day:"+d.getDay());
alert("seconds:"+d.getSeconds());
alert("time:"+d.getTime());
}
</script>
<body>
<input type="button" value="check timing" onclick="checkdate()">
</body>