Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Re: Problem with form added to innerHTML dynamically..

Expand Messages
  • Kevin Duffey
    Hi, Thank you for the reply. I am not quite sure what you mean to be honest. Are you saying that if I want to grab the element by its ID, NOT to set its name
    Message 1 of 4 , Jul 30, 2006

      Thank you for the reply. I am not quite sure what you mean to be honest. Are you saying that if I want to grab the element by its ID, NOT to set its name as well?

      So, I found an example on the net that on the keyup event updates the value. Basically, that's what I am doing now. I don't need the <form> tag, just the input box. So as each key is typed, I set a global variable to the input field, then when they hit ADD I just attach to the post params the value that was updated with each keystroke. This works fine, but seems kind of wasted that I need to update my own variable each time a key is pressed. I still can't see why the input box was NOT setting the elem.value right away as I typed, so that I could get it immediately within my javascript code. I thought maybe I had to add it to the document object itself, rather than inserting it in the innerHTML value of a div tag. I recall reading that if you use innerHTML, you can NOT access the dom elements that are inserted into innerHTML as they aren't added to the dom tree. Which is why I thought maybe that was why the input box wasn't working right.. maybe the browser (firefox was seeing an <input> not wrapped in <form></form> and was basically ignoring it for some odd reason.

      Anyway, I wouldn't do this in a large form if I could avoid it, but for a single line entry its not a big deal. Any other ideas?

      sgrandhisila <sgrandhisila@...> wrote:
      Hi Kevin,

      Please make sure that each and every Input element has the name and
      Id properties.

      If you assign the Id with some name and ask call with that id.

      It will work for you exactly.

      Make sure that dont set the name property..

      Srini....... .

      <input type=text id="t1" value="100">

      --- In ydn-javascript@ yahoogroups. com, Kevin Duffey <andjarnic@. ..>
      > Hey there,
      > I am trying to figure out if the problem I am seeing is related to
      the YAHOO api, or just the general way browsers deal with forms. I
      have read and heard that forms are like a special object.
      > My problem is, I use the yahoo dialog widget to display a popup
      modal dialog. Instead of having the <div> stuff within the main page
      and hidden, I dynamically add it to a simple StringBuffer, then set
      the innerHTML of the element inside the <div class="db"> tag, and it
      all shows up nicely. The form, colors, etc.
      > The problem is, when the javascript code is called when the
      save/close button is selected (I provide that as part of the
      contents to show in the dialog), everything seems fine. I am able to
      do something like:
      > var inp = document.getElement ById("inputBox" );
      > alert(inp.name) ; // works every time.. shows the right name
      > alert(inp.type) ; // always shows TEXT
      > alert(inp.value) ; // almost never works.
      > The problem is, I basically use the AJAX post call to send data,
      and do NOT submit forms. So since this dialog only has a single
      input box, I simply grab the input box (it has id set), and read its
      value that the user typed. So far tho, the value eludes me! Most of
      the time!!! Thats the odd thing, sometimes the value shows what I
      typed, but most of the time its empty. It's as if the input box
      isn't storing what I typed into the value property for me to access.
      > I am wondering if the innerHTML does not properly add input boxes
      and such to the document? I mean, if they work correctly, why
      wouldn't I be able to get the value? I've even tried putting a
      timeout in to see if after 1 second the value is available, still no
      > Any help on why a form and/or input box wouldn't work when set
      through the innerHTML would be very much appreciated.
      > Thank you.
      > ____________ _________ _________ _________ _________ __
      > Do You Yahoo!?
      > Tired of spam? Yahoo! Mail has the best spam protection around
      > http://mail. yahoo.com

      Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.

    Your message has been successfully submitted and would be delivered to recipients shortly.