How do I auto-update 1 list based on selection in another?

Here you can find plenty of help with your general coding needs and projects
If it is about a specific program, use the corresponding forum
DO NOT ask basic questions such as "How do I print a variable", use Google for that

How do I auto-update 1 list based on selection in another?

Postby DreadPickle » Sat Aug 12, 2006 7:59 am

How do I auto-update 1 list based on selection in another?

Semi-working example:
Meat Vendor Roster - Talents

In the example, selecting a Class does nothing until you click "Apply" THEN, and only then, does it limit the options in the Talents dropdown list.

I'd like it to automatically limit the Talents list when a class is selected.

Is there an "On Update" action for selects?

(Yes, I am a n00b coder! :smile: More self-taught hack-n-slash than code, tho)

Thanks in advance for your help!
Last edited by DreadPickle on Sat Aug 12, 2006 6:14 pm, edited 1 time in total.
Image
User avatar
DreadPickle
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 33
Joined: Sat Jul 08, 2006 6:23 am

How do I auto-update 1 list based on selection in another?

Postby ThePrimaryDave » Tue Aug 15, 2006 2:38 am

I think the javascript event you want is "onChange" (though the capitalization may be wrong).
ThePrimaryDave
WR.net Apprentice
WR.net Apprentice
 
Posts: 64
Joined: Wed Jul 05, 2006 9:45 pm
Location: Central Coast of CA

How do I auto-update 1 list based on selection in another?

Postby Subxero » Tue Aug 15, 2006 7:50 am

Last edited by Subxero on Tue Aug 15, 2006 7:51 am, edited 1 time in total.
User avatar
Subxero
WR.net Artisan
WR.net Artisan
 
Posts: 234
Joined: Thu Jul 06, 2006 4:08 pm
Realm: Zul'jin (PvE) - US

How do I auto-update 1 list based on selection in another?

Postby MattM » Tue Aug 15, 2006 7:58 am

javascript is fun.


use firefox to troubleshoot your JS, using the slick javascript console ;)
Last edited by MattM on Tue Aug 15, 2006 7:58 am, edited 1 time in total.
MattM
UA/UU Developer
UA/UU Developer
Gimpy Developer
Gimpy Developer
 
Posts: 886
Joined: Tue Jul 04, 2006 9:53 pm
Location: USA

How do I auto-update 1 list based on selection in another?

Postby DreadPickle » Mon Aug 21, 2006 8:50 am

Thank you kindly for the links. I hadn't considered JavaScript, but they sent me off on a chase. Here's a little update.

I found this tutorial at Zend.com. But wasn't satisfied with it or the lack of response in the comments.

Next I found this post at PHPBuilders.com that had a few near misses until I saw this link to yxscripts.com. Almost what I wanted.

I kept looking until I found JSRS select demo at Ashley IT which was exactly what I was looking for.

I implemented it and got it to work ... IF I didn't use addon.php. :scratch: Something about
Code: Select all
jsrsError: function builds as empty string.
with
Code: Select all
document.forms.frmtalented has no properties.

JavaScript - http://s94197980.onlinehome.us/mv/roster/addon.php?roster_addon_name=talented
Event thread: load
Error:
name: TypeError
message: Statement on line 149: Could not convert undefined or null to object
Backtrace:
  Line 149 of linked script http://s94197980.onlinehome.us/mv/roster/addons/talented/selectphp.js
    var lst = document.forms["frmtalented"][listNAME];
  Line 26 of linked script http://s94197980.onlinehome.us/mv/roster/addons/talented/selectphp.js
    emptyList("lstClass");
  Line 37 of linked script http://s94197980.onlinehome.us/mv/roster/addons/talented/selectphp.js
    initLists();
  Line 1 of  script
    preselect("Druid", "-99", "-99", 1);
  At unknown location
    [statement source code not available]


But if I comment out the
Code: Select all
jsrsDispatch( "ClassList TreeList TalentsList" );
line in select_rs.php (which is what returns the error) all script files appear to be accessed as scripts from all of them clear the defaults I place in the drop-down lists, yet the lists don't repopulate and I get nothing in any Java console.

Meat Vendor Talented is currently set with the "jsrsDispatch" live if anyone want to give it a look-see.

So, while not query-derived and database driven, I'm going to use the chainedselects from yxscripts.com as they seem simpler to implement until I can figure out how the JSRS is broken. Unless, of course, they suffer the same problems when I actually get them implemented. :???:

-dP
Last edited by DreadPickle on Mon Aug 21, 2006 6:45 pm, edited 1 time in total.
Image
User avatar
DreadPickle
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 33
Joined: Sat Jul 08, 2006 6:23 am

How do I auto-update 1 list based on selection in another?

Postby DreadPickle » Mon Aug 21, 2006 11:18 pm

Another quick update:

OK. Since I seem to be having the same problem with my new plan of attack it looks like I just need to troubleshoot the way javascript passes form references.

I placed all the code in the index.php except the .js. When I access the page through addon.php it doesn't work, but if I hit it directly it does.

(links removed because I think I fixed it.)
NOT working - using addon.php
Working - direct access
(/links removed because I think I fixed it.)

Looks like I'm back to the w3schools java refernce for help on how java passes the form name/location between pages.
Last edited by DreadPickle on Tue Aug 22, 2006 6:29 pm, edited 1 time in total.
Image
User avatar
DreadPickle
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 33
Joined: Sat Jul 08, 2006 6:23 am

How do I auto-update 1 list based on selection in another?

Postby PleegWat » Mon Aug 21, 2006 11:58 pm

For some weird reason it seems to work here. But I think I've got your problem. You need to post roster_addon_name as get, not post. So just use "addon.php?roster_addon_name=talented2" as submit url.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

How do I auto-update 1 list based on selection in another?

Postby DreadPickle » Tue Aug 22, 2006 6:27 pm

Sorry about that. I was working on that when I should have been working yeaterday... I was wondering why i kept losing the parameters - I'll change that right away!

I think I've fixed it and now it's on to clean up, more features, and documentation.

I used the ChainedSelects script from yxscripts and placed everything in the index.php except the localization, the 2 .js files and menu. Since I had to use a "body onload=" script I copied the roster_header.tpl there as well.

I hope that doesn't violate any design standards so I'm off to re-read the AddonSDK wiki to make sure. As soon as I have things tidied up, I'll upload to the 3rd-party addon forum for perr-review and general usage.

Thanks for your comments!
Last edited by DreadPickle on Tue Aug 22, 2006 6:36 pm, edited 1 time in total.
Image
User avatar
DreadPickle
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 33
Joined: Sat Jul 08, 2006 6:23 am


Return to General Code Help

Who is online

Users browsing this forum: No registered users and 0 guests

cron