Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-21-2013, 08:55 AM   PM User | #1
varalakshmi
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
varalakshmi is an unknown quantity at this point
On change event not fired with dynamically loaded data

I am dynamically loading data in the input type text and triggering alert if the value of the text box is changed. But my code does not seem to work. Please provide suggestions.
Code:
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("input").val("value");
});
function valueChanged()
{
alert("value changed");
}
</script>
</head>
<body>

<input type="text" onchange="valueChanged()">
<p>Write something in the input field, and then press enter or click outside the field.</p>

</body>
</html>

Last edited by VIPStephan; 01-21-2013 at 09:49 AM.. Reason: corrected code BB tags
varalakshmi is offline   Reply With Quote
Old 01-21-2013, 11:06 AM   PM User | #2
Kyle123
New Coder

 
Join Date: Jan 2013
Posts: 10
Thanks: 3
Thanked 1 Time in 1 Post
Kyle123 is an unknown quantity at this point
Since you're using JQuery, why not:

PHP Code:
        <script>
            $(
document).ready(function(){
                
                $(
"input").val("value");

                $(
"input").change(function() {
                    
alert("changed");
                });
            });
            
        
</script>
    </head>
    <body>
        <input type="text" id="text1"/>
    </body> 
Working example: http://jsfiddle.net/96gXw/
Kyle123 is offline   Reply With Quote
Reply

Bookmarks

Tags
events, javascript

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:03 PM.


Advertisement
Log in to turn off these ads.