Got a static var which is working, now need to get dynamic var which isnt working
Posted
by Ritz
on Stack Overflow
See other posts from Stack Overflow
or by Ritz
Published on 2010-04-08T13:07:14Z
Indexed on
2010/04/08
13:23 UTC
Read the original article
Hit count: 201
jQuery
got this variable
var zvmlist = {
'Huishoudelijke hulp': 'Huishoudelijke hulp',
'Verpleging thuis': 'Verpleging thuis',
'Verzorging thuis': 'Verzorging thuis',
'24 uurs zorg': '24 uurs zorg',
'Ondersteunende begeleiding': 'Ondersteunende begeleiding',
};
this var is used in a function to create a dropdownlist.
$.each(zvmlist, function(key, value) {
var selected='';
if(key==eventdata.title){var selected='selected' }
$('<option value="'+key+'" '+selected+'>'+value+'</option>').appendTo($('#calendar_edit_entry_form_title'));
});
which works lika a charm. Now i created a function to fetch the list from a mysql table.
$.get('get_zorgvormen.php', function(data) {
var zvmlist = '{'+data+'}';
//alert(zvmlist);
});
when i enable the alert function it shows me the var(array). But i it wont act as a variable. How can i pass this data to my .each function?
see it in action here: http://www.zorgzuster-zeeland.nl/site/static/calendar_test.php
© Stack Overflow or respective owner