简体   繁体   中英

javascript not working in IE with radio button onClick

I have some code which acts as a redirect and sets some values when a user clicks on a radio button. In chrome and firefox these scripts work perfectly however in IE nothing seems to happen at all.

HTML

<td>
    <input type='radio' id="order_type6" name='order_type' value="5"
        onClick="selectOrderType('1')">
    <label for="order_type6"><strong>Facility Employee</strong></label>
</td>
<td>
    <input type='radio' id="order_type7" name='order_type' value="5" 
        onClick="selectOrderType('1')">
    <label for="order_type7"><strong>Private Contract</strong></label>
</td>

JS function:

function selectOrderType(type)
{
    console.log(type);
   //replace '&load=1' with '&neworder=1'
    $location = window.location.href.replace(/&load\=1/,'&neworder=1#');
   //replace '#' at the end of the string with '' + $ordertype
    window.location.href = $location.replace(/#?$|&order_type\=\D?/,'&order_type='+type);
}

Remove the console.log - or press F12 to open the console.

IE does not support console if it is not open

'console' is undefined error for Internet Explorer

Or change to window.console && console.log(type)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM