Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript Help

Options
  • 30-07-2008 9:49am
    #1
    Registered Users Posts: 3,401 ✭✭✭


    Lads again my JS knowledge is letting me down in AJAX.

    My ajax is returning the code
    addPubNum( 5940, '1796 Wolfe Tone Bar' , 'pubid1' );
    

    This function can be seen here:
    function addPubNum( id, name, pubnum ) {document.forms['addpub'].elements[ pubnum ][ document.forms['addpub'].elements[ pubnum].length ] = new Option( name, id );}
    

    The problem is that this function/code isn't populating the form:
    <table width="100%">	<form name="addpub" action="userpage.php" method="GET">
    																
    	<tr><td colspan="2">Please Enter Your 1st Pub</td></tr>
    	<tr><td><select name="countyid" onChange="showPubNum(1,this.value);"><option value="0">Select County</option>
    	<option value="1">Antrim</option>
    	<option value="2">Armagh</option>
    	</select></td>		
    	<td><select name="pubid1"><option value=""></option></select> </td></tr>
    	<tr><td colspan="2" align="right"><input type="submit" value="Add"></td></tr>
    
    	</form></table>
    


    If anyone could see an error off the top of their head that would be great!

    P.S. -> showPubNum(1,this.value); is working fine!


Comments

  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    It works fine for me when I call the addPubNum from a button, so perhaps it's the way the function is being called.


  • Registered Users Posts: 3,401 ✭✭✭randombar


    That's strange?

    The page can be found here: http://www.ratemypub.ie/userpage.php the ajax is ran when you select a county.

    Using the basic:
    eval( xmlHttp.responseText  )
    

    to call it?


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    I think I found it.

    try changing this:
    xmlHttp.onreadystatechange = stateChangedPubNum()
    to
    xmlHttp.onreadystatechange = stateChangedPubNum


  • Registered Users Posts: 3,401 ✭✭✭randombar


    Woo Hoo, LEGEND!


Advertisement