I have made a simple javascript function that gets executed on button click –
<asp:TextBox ID="TextBox3" runat="server" Width="98px"></asp:TextBox>
<asp:Button ID="Button3" runat="server" Text="Button" OnClientClick="fn4();" />
<script type="text/javascript">
function fn4()
{
var search = document.getElementById('TextBox3').value;
<iframe src="http://fooBar.com/q=" + search + " width="250" height="400" scrolling="no" frameborder="0"></iframe>
}
</script>
So the search term is based on the user input from TextBox3, however when this is executed, it brings up the error –
Error: 'fn4' is undefined
How can I resolve this?
You’re probably getting a parser error in your browser when the page loads. And because the JavaScript isn’t parsing, the function isn’t defined. This is invalid JavaScript:
There’s HTML mixed in there, so it won’t parse as JavaScript. What exactly are you trying to do with that
iframe?