Hi All Am trying to echo a PHP variable in a line of javascript but I cant get it to work, am hoping someone could help. I have the following line as part of a link: <a href="javascript:toggleLayer('NAME');" Code (markup): but need to replace NAME with a variable. Have tried this but I couldnt get it to work: <a href="javascript:toggleLayer('<?php echo $value['VARIABLE']; ?>');" Code (markup): Would anyone have any ideas? Thanks!
Do you know what's not working? The code below should produce: $value['VARIABLE'] = 'div_1'; <a href="javascript:toggleLayer('div_1');" PHP:
Hi jestep for some reason it just doesnt echo the varibale, so it just returns () in the link. Not sure why.
Ahhh actually, I think ive just realised why it doesnt work. My apologies, the above code does work. Its the actual sending of the variable that I made a mistake in! Sorry, but thanks!
<script type="application/javascript"> function addAnother() { jQuery('#addprodbox').append('<select name="prodArray[]" id="prodArray[]"> <?php $prodlookup = "SELECT prodID, name FROM bolt_shop_prod"; $proddata = mysql_query($prodlookup) or die('Failed to return data: ' . mysql_error()); while($option = mysql_fetch_array($catdata)) { echo '<option value="' . $option['prodID']. '">' .$option['name'].'</option>'; } ?> </select>'); } </script>