Lokesh Paunikar
Lokesh Paunikar

Reputation: 1709

java script: onblur() working in opera but not in mozilla

This is my code :

<script>
function showVehical(type){
var element = document.getElementById('TotalCoach');
element.onblur="myfunction(type);";
}

function myfunction(type){
alert(type);
}

</script>

<HTML>
<body>
<input type="text" name="totalNumberOfCoach" id="TotalCoach" value="1"/>
</body>
</HTML>

The above code is working fine on opera but not in mozilla onblur() not working.

Upvotes: 0

Views: 469

Answers (2)

Tom Belote
Tom Belote

Reputation: 590

Where do you call showVehical()? It needs to be after the TotalCoach input field is ready. This code works for me:

<script>
function showVehical(type){
var element = document.getElementById('TotalCoach');
element.onblur=function() {myfunction(type);};
}

function myfunction(type){
alert(type);
}
</script>
<HTML>
<body>
<input type="text" name="totalNumberOfCoach" id="TotalCoach" value="1"/>
<script>
showVehical("a");
</script>
</body>
</HTML>

Upvotes: 1

CGK
CGK

Reputation: 2662

Try using a javascript library (like jQuery), to eliminate discrepancies between browsers.

Upvotes: 1

Related Questions