This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ajax : how to replace another option list?

 
Nakata kokuyo
Ranch Hand
Posts: 465
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day everyone, i'm new to ajax, and having my try using prototype

if i have 2 select option list, say seletOption and updateOption , when onchange on seletOption, updateOption will update and change value based on choice of seletOption



the callAjax() function as follow :



my doubt are :

1)how do we update the updateOption ?
2)for generate the choice of updateOption, i was thinking return a xml which contains all value for updateOption in following format



- in prototype, is there a way to parse xml ? or normally how to parse xml in usual?
- is it good to return xml in this case ? any other choices ?

many thanks in advance for guidance
[ October 11, 2006: Message edited by: Nakata kokuyo ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nakata kokuyo:
1)how do we update the updateOption ?


The select element has an API that can be used to manipulate it. You should have a JavaScript and HTML DOM reference handy. Without such a reference you will continually struggle.


2)for generate the choice of updateOption, i was thinking return a xml which contains all value for updateOption in following format


Not a great choice. Returning a JSON structure that you can easily traverse with JavaScript would be much easier.

- in prototype, is there a way to parse xml ? or normally how to parse xml in usual?


If you decide to ue XML, you would parse it as usual given the XML document returned by the XHR instance. Prorotype's $A() function will help you traverse node lists.

is it good to return xml in this case ? any other choices ?


See above.
[ October 11, 2006: Message edited by: Bear Bibeault ]
 
Nakata kokuyo
Ranch Hand
Posts: 465
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you and have a nice day, Bear Bibeault ,

do you mind to show me the most useful and frequent reference on javascript and DOM reference as you mentioned ?

thanks again for guidance , bear
 
Nakata kokuyo
Ranch Hand
Posts: 465
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Bear Bibeault for the guidance
 
Nakata kokuyo
Ranch Hand
Posts: 465
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi bear, i have figure out how to replace the option list, but somehow i have some question on it , i have xml file in format as follow :


and have 2 option list as follow :
when "myoption" onchange, it will change the option in "changeoption"



and below is the callback function to replace "changeoption" option



this code work fine and it does replace the changeoption, however if i replace the line



to



it didn't give any error but the changeoption list is not change, i did output retLabel and retValue, it show the value correctly ,besides, i also try on using new String(retLabel), but it doesn't help

why is it so ?
thank you
[ October 12, 2006: Message edited by: Nakata kokuyo ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic