Jump to content

Jquery & PHP String Literals...


sleepingpeace

Recommended Posts

I'm retrieving a height value from a database as a string that is valued as 5'6", 6'11", etc...

 

My code is this

 

$('select[name=height] option').each(function ()

{

    if ($(this).val() == '<?php echo $height ?>')

$(this).attr('selected', 'selected');

});

 

What I'm doing here is going through each option in a select dropdown and comparing the retrieved value from the database to the option's value and auto-selecting that option when the match is found. The issue is that the height value, say 5'6", contains a single and double quote which terminates the string in the evaluation prematurely. What is the best option to fix this?

Link to comment
https://forums.phpfreaks.com/topic/250895-jquery-php-string-literals/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.