Instead of using 'inline' with drupal_add_js(), consider using 'setting' instead and passing it an array, which will be available in the same fashion as Drupal.settings.basePath. <a href="http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_add_js/6">http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_add_js/6</a><br>
<br><div class="gmail_quote">On Mon, Dec 6, 2010 at 10:31 AM, Aldo Martinez Selleras <span dir="ltr"><<a href="mailto:aldo@caonao.cu">aldo@caonao.cu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I'm creating a select box dynamically from JSON data, and setting up a<br>
selected value in URL, but I have a problem.<br>
<br>
http://...../gallery/2<br>
<br>
My php code:<br>
$selected = arg(1);<br>
<br>
if ( $selected ) {<br>
drupal_add_js('var url_class = '. $selected, 'inline');<br>
}<br>
<br>
<br>
My javascript code:<br>
<br>
$('#class-filter').addOption({'0':' -- ALL -- '},false);<br>
$('#class-filter').ajaxAddOption(Drupal.settings.basePath +<br>
'gallery/class',{},true, my_selectOption);<br>
<br>
function my_selectOption(){<br>
$(this).selectOptions( '' + url_class + '', true );<br>
}<br>
<br>
var classification = $('#gallery-classification-filter').val();<br>
<br>
<br>
The select box is created OK, and the value showed as selected is ==<br>
url_class, but the value of the object still is 0.<br>
<br>
The question:<br>
<br>
Why classification value == 0??? must be == url_class!!<br>
<font color="#888888"><br>
<br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</font></blockquote></div><br>