Friday, July 27, 2012

Modals and Javascript Tip - Forcing Textbox Value Update

I had an interesting challenge surface in attempting to reference a textbox wrapped in a modal div. Interestingly, the text box wouldn't update it's own value attribute. I couldn't conclusively determine the exact cause of this issue, other than it only occurred, so long as the textbox box was encapsulated within the the modal div. To resolve this, I created a simple function within the modal to force the texbox value to populate into the value attribute. Presto!


<input type="text" id="addressBox" onblur="javascript: fixValue(this.value);" />
        <script type="text/javascript">
        function fixValue(fixThis)
        {
        fixThat = document.getElementById('addressBox');
        fixThat.value = fixThis;
     
        }
        </script>

No comments:

Post a Comment