Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Javascript Help

  • 30-07-2008 08:49AM
    #1
    Registered Users, Registered Users 2 Posts: 3,487 ✭✭✭


    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, Registered Users 2 Posts: 21,279 ✭✭✭✭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, Registered Users 2 Posts: 3,487 ✭✭✭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, Registered Users 2 Posts: 21,279 ✭✭✭✭Eoin


    I think I found it.

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


  • Registered Users, Registered Users 2 Posts: 3,487 ✭✭✭randombar


    Woo Hoo, LEGEND!


Advertisement