Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
57
rated 0 times [  58] [ 1]  / answers: 1 / hits: 59733  / 12 Years ago, thu, april 12, 2012, 12:00:00

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;
}

More From » php

 Answers
32

onchange=javascript:valueselect() replace with onchange=valueselect(this.value);



function valueselect(myval)
{
window.location.href = channelinformation.html?selected=+myaval;
}


You Can Use Directly



onchange=window.location='channelinformation.html?selected='+myaval

[#86287] Wednesday, April 11, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kristinsonjab

Total Points: 364
Total Questions: 98
Total Answers: 98

Location: Christmas Island
Member since Mon, Oct 19, 2020
4 Years ago
kristinsonjab questions
Fri, Mar 4, 22, 00:00, 2 Years ago
Fri, Jan 22, 21, 00:00, 3 Years ago
Fri, Aug 14, 20, 00:00, 4 Years ago
;