onchange event of select box

Posted by Priyanka on Stack Overflow See other posts from Stack Overflow or by Priyanka
Published on 2012-04-12T10:47:41Z Indexed on 2012/04/12 11:29 UTC
Read the original article Hit count: 253

Filed under:
|
|

I am using a selectbox to display the list of "enterpirses" from the database. But the onchange event is not triggering. But when i manually once put the value of querystring then it starts working. I dont understand why it is happening.

I am new to javascript and php, kindly suggest me the solution to this.

<select id="enterprisebox" onchange="javascript:valueselect()" >
    <option value="-">-</option>

    <?php foreach($enterprise as $val) { ?>
    <option value="<?php echo $val['customer_id'];?>"><?php echo $val['customer_name']?>
    </option>
    <? } ?>

</select>

and my javascript is--

function valueselect()
{
    var i = document.getElementById('enterprisebox');
    var p = i.options[i.selectedIndex].value;
    //alert(p);
    window.location.href = "channelinformation.html?selected="+p;
}

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript