On the host the php generated javascript drops an error of:
missing ; before statement
At the same time on localhost it works fine.
the generated code was :
try{
obj = document.getElementById('subcat');
}catch(e){}
try{
obj.innerHTML = "<select name=\"sub_ad_category_id\">
<option value=\"\">-</option>
<option value=\"5\">bootle</option>
<option value=\"3\">Puzzle</option>
</select>";
}catch(e){}
It is generated by action.php by the next code:
if($var_type=='array') $text = '<select name="+ads_data[sub_ad_category_id]+">';
else $text = '<select name="sub_ad_category_id">';
$text .= '<option value="">-</option>';
$res = $ads->get_ads_categories($_SESSION['lang'],$parent_id);
while($r = mysql_fetch_array($res)){
$text .= '<option value="'.$r['ad_category_id'].'">'.$r['category_name'].'</option>';
}
$text .= '</select>';
echo "try{obj = document.getElementById('".$id."');}catch(e){}";
echo "try{obj.innerHTML = ".$text.";}catch(e){}";
Look at this line ...
obj.innerHTML = "<select name="sub_ad_category_id"><option value="">-</option></select>";
... modifications (missing some +
signs and changed double quotes at value to single ''
)
obj.innerHTML = "<select name=" + sub_ad_category_id + "><option value=''>-</option></select>";
+
is simple concatenation.''
single quotes is one way of including quotes in final HTML cleanly; otherwise, you could have used \"\"
slash escaped quotes.UPDATE:
Given what I see of your changes above, it looks like how you are building the string. Don't use the enter key when building strings. Try like this ...
var html = "<select name=\"sub_ad_category_id\">";
html += "<option value=\"\">-</option>";
html += "<option value=\"5\">bootle</option>";
html += "<option value=\"3\">Puzzle</option>";
html += "</select>";
ob.innerHTML = html;
... OR ...
ob.innerHTML = "<select name=\"sub_ad_category_id\"><option value=\"\">-</option><option value=\"5\">bootle</option><option value=\"3\">Puzzle</option></select>";
See this jsFiddle