Two <div> ID Problem with AJAX

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmccarroll
    New Member
    • Aug 2008
    • 1

    Two <div> ID Problem with AJAX

    I have to two select boxes with values and two javascripts which call server-side scripts. The first select box will write to the first <div id='txtHint1'></div>, but when I intoduce a second <div id='txtHint2'></div>, the first select box writes to there instead of <div id='txtHint1'></div>.

    First Select Box

    Code:
    onchange='javascript:showCertificates(this.value)
    Second Select Box

    Code:
    onchange='javascript:showEndorsements(this.value)
    First JS

    [CODE=javascript]function stateChanged()
    {
    if (xmlHttp.readyS tate==4 || xmlHttp.readySt ate=="complete" )
    {
    document.getEle mentById("txtHi nt1").innerHTML =xmlHttp.respon seText
    }
    }
    [/CODE]
    Second JS

    [CODE=javascript]function stateChanged()
    {
    if (xmlHttp.readyS tate==4 || xmlHttp.readySt ate=="complete" )
    {
    document.getEle mentById("txtHi nt2").innerHTML =xmlHttp.respon seText
    }
    }[/CODE]
    Last edited by acoder; Aug 22 '08, 09:37 AM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The problem is you've used the same function name. Use a different function name, even something as simple as stateChanged2() .

    PS. please remember to use code tags when posting code. Thanks!

    Comment

    Working...