html - element onChange javascript not working - Stack Overflow

<select name='cmg_select'onChange="javascript:window.location.href='index.php?

<select name='cmg_select'  onChange="javascript:window.location.href='index.php?'+this.value">
    <option value='pening'> pening </option>
    <option value='plete'> plete </option>
    <option value='pening'> pening </option>
</select>

The concatenation is not working.

<select name='cmg_select'  onChange="javascript:window.location.href='index.php?'+this.value">
    <option value='pening'> pening </option>
    <option value='plete'> plete </option>
    <option value='pening'> pening </option>
</select>

The concatenation is not working.

Share Improve this question edited Mar 2, 2016 at 5:43 Caleb Eby 3864 silver badges14 bronze badges asked Jul 4, 2010 at 7:02 BharanikumarBharanikumar 25.7k50 gold badges135 silver badges201 bronze badges 2
  • 1 onChange can and should be written onchange . – Pekka Commented Jul 4, 2010 at 7:33
  • And you shouldn't have two items with the same label and value. – Pekka Commented Jul 4, 2010 at 7:33
Add a ment  | 

3 Answers 3

Reset to default 3
  1. Remove the javascript: portion
  2. Remove the href portion

The result :

< select name='cmg_select' onchange="window.location='index.php?'+this.value" >

Try this instead

<select name='cmg_select' onChange="window.location.href='index.php?'+this.options[this.selectedIndex].value">
<option value='pening' > pening </option>
<option value='plete' > plete </option>
<option value='pening' > pening </option>
</select>

Remove the javascript: from the onchange attribute.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744591666a4582642.html

相关推荐

  • html - element onChange javascript not working - Stack Overflow

    <select name='cmg_select'onChange="javascript:window.location.href='index.php?

    1天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信