I’m looking to get the value of this input if it changes. I have a map.swf that makes the value change depending on what the user selects in the .swf, so I was wondering how to get this done.
<a href="map.php" onclick='return GB_showCenter("",this.href,380,780);' class="page">See Map</a>
<input name="sector_e" type="text" id="sector_e" value="Please click The Map" size="1" readonly>
This jQuery only alerts me if I press a key, I want it to alert if the value changes without any event.
$('#sector_e').bind("keyup", function() {
alert($(this).val());
});
You will need to do a combination of things:
datacommand capabilities to save the initial value.focusoutorblurorchangeevent to check the current value against what is saved usingdata.Which even you choose depends on whether or not direct user-interaction is possible or not. Further processing can happen once you detect a change.
FOR EXAMPLE:
You might consider marking the element with a class name like “isDirty” using jQuery’s
addClasscommand.Then you could do things like:
In the meantime…
HERE IS A CODE SAMPLE USING FOCUSOUT:
Of course, doing it this way is taxing as you would have to write a separate set of calls for each
textbox.So, why not add a class name to each
textboxand do it this way…A BETTER EXAMPLE USING FOCUSOUT: