Get the value of the select box in ie

We can’t access the option value using javascript on Internet Explorer using the normal javascript method.ie we cant get the value of the select box in ie

IE is looking for the value attribute. It looks like other browsers are defaulting to the text displayed as the value if value=”” is not found on the option tag. The following is what works on all major browsers.

<form name="myform">
    <select id='select' name="select">
        <option value='one'>one</option>
    </select>
</form>
<script>
    var index = document.myform.select.selectedIndex;
    var value = document.myform.select.options[index].value;
    alert(value); // Alerts 'one'
</script>

By this code we can get the value of selectbox

Call fancybox on page load

Some time we need to show an message in popup when someone enters in our website.Its easy to call fancybox on page load

when we use fancy box

make sure you have included fancybox core files and jQuery

Here is the code to do so

$(document).ready(function(){
 
    var popup= $('#popup');
 
    $.fancybox(popup);
 
})

And the popup html element as follows

<div id="popup" style="display:none;"><h2>Sample Content</h2></div>

This will help you to call fancybox on page load

How to clear the placeholder on focus

By default place holder will stay there when we click on the text box, We can do it by writing simple code with javascript
as follows

<script type="text/javascript">
$(function(){
    $("input:text").each(function ()
    {
        // store default value
        var v = $(this).attr('placeholder');
    
        $(this).focusin(function ()
        {
           $(this).attr('placeholder','');
        }).focusout(function ()
        {
            $(this).attr('placeholder',v);
        }); 
    });
})
</script>

Don’t forget to include jQuery

The above code is mentioned only for text boxes we can add it for textarea also