Bookmarking callback

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Grumps
    New Member
    • Mar 2007
    • 3

    Bookmarking callback

    Im trying to build a bookmarking feature with ajax and everything has work until i come across the callback problem.

    document.getEle mentById during stateChanged

    Im trying to make possible
    Code:
    document.getElementById(id).innerHTML=xmlHttp.responseText
    as im having multiple div id on my page each page will have 15 mysql result and will be ID by their ID. For example
    Code:
    <div id="1"></div><div id="2"></div><div id="3"></div>
    I have no idea why but it doesnt seem to work but would only work when i place getElementById as a fixed value such as
    Code:
    document.getElementById("msg").innerHTML=xmlHttp.responseText
    for
    Code:
    <div id="msg"></div>
    in this way, i cant perform any unique response to my list of mysql result. Please help.
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    welcome to the scripts .... i think u don't change the div style like ...

    style = "height:Ypx;wid th:Xpx"

    i think u got my point ... best of luck

    Comment

    • Grumps
      New Member
      • Mar 2007
      • 3

      #3
      Originally posted by dmjpro
      welcome to the scripts .... i think u don't change the div style like ...

      style = "height:Ypx;wid th:Xpx"

      i think u got my point ... best of luck
      Nah, i wasnt trying to change the style, it was to retrieve an echo result on stateChange. Anyway, i have found my solution to it. Thanks anyway.

      Comment

      • djoldfield
        New Member
        • Jun 2007
        • 1

        #4
        One comment about your preceeding naming conventions (with respect to Div Id). While JavaScript will treat a number as a string, it is a very bad idea to ask it to do so with respect to Div Element Ids. Some browsers (Ex. Internet Explorer) use direct DOM calls to retrieve a Div element By Id, and the function called will try to treat the value as a number first. Document element 2 is not nececessarily the object with ID of 2. Try using "elem2" as an ID (for example). It is a good practice that all identifiers both in formatting, scripting, and logic are using a legitimate string as it's identifying value (name or ID). This (of course) does not apply to databases, but at least it prevents ambiguities in typeless languages.

        Comment

        Working...