Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    contents of textbox erased after tabbing to next textbox

    I have several data entry pages in my Web application, and they have textboxes that need to appear when their labels (property names) are clicked, and disappear when their labels are double-clicked. I'm using JavaScript to make this happen (see code below), but for some reason, the only way I can enter any text into a textbox is if I keep the mouse-button pressed down within the textbox while I'm entering something. (I'm seeing this w/both IE and Firefox). But when I tab to the next textbox, what I entered in the previous textbox disappears. Is there any way to fix this?

    JavaScript code to display the property name, textbox and label:

    document.getElementById("div" + className).innerHTML = newClassName + "<br><input type='text' name='txt" + className + "' onBlur='javascript:updateDOM(this);' />" + label;

    JavaScript code to just display the property name:

    document.getElementById("div" + className).innerHTML = newClassName;

  • #2
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Just a quick follow-up

    If the browser behavior I've described in my original message is unavoidable, then I'll probably need to change my application's behavior, so I'm open to suggestions on that.


    Quote Originally Posted by aroc725 View Post
    I have several data entry pages in my Web application, and they have textboxes that need to appear when their labels (property names) are clicked, and disappear when their labels are double-clicked. I'm using JavaScript to make this happen (see code below), but for some reason, the only way I can enter any text into a textbox is if I keep the mouse-button pressed down within the textbox while I'm entering something. (I'm seeing this w/both IE and Firefox). But when I tab to the next textbox, what I entered in the previous textbox disappears. Is there any way to fix this?

    JavaScript code to display the property name, textbox and label:

    document.getElementById("div" + className).innerHTML = newClassName + "<br><input type='text' name='txt" + className + "' onBlur='javascript:updateDOM(this);' />" + label;

    JavaScript code to just display the property name:

    document.getElementById("div" + className).innerHTML = newClassName;

  • #3
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    You're going about hiding your textboxes in an odd way - by actually deleting them.

    You can use element.style.display="none" and element.style.display="block" to hide/show html elements. (You can also use visibility="hidden" and visibility="visible" to keep the element in the flow of the page while hidden.) This way your inputs won't be removed from the page and will maintain their values.
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • Users who have thanked itsallkizza for this post:

    aroc725 (12-25-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •