I have song titles that I am placing - ANY song that has an apostrophe breaks the the code - For example, when I try to ad "That's Alright", it registers as "That" because the ' breaks. Here is the isolated line of code. Can someone recommend a fix that will replace the ' with \' ?
"<input type='hidden' name='title' value='"+val.sources[0].title+"'>"+
tried a variation of code from W3 Schools
var str = "Visit Microsoft!";
var res = str.replace("Microsoft", "W3Schools");
But I believe the syntax was off...
"<input type='hidden' name='title' value='"+val.sources[0].title+"'>"+
I want the hidden field value to not break at the '
<?php if($playlist!='fav' && $membership == '2'){ // REMOVED $list ?>
"<form id='addFavorite' action='process_fav_add_pro_preview.php?p=<?php echo $playlist; ?>' method='post'><input type='hidden' name='favid' value='"+val.sources[0].track_id+"'>"
+
"<input type='hidden' name='mediatype' value='"+val.sources[0].media+"'>"+
"<input type='hidden' name='title' value='"+val.sources[0].title+"'>"+
"<input type='hidden' name='artist' value='"+val.sources[0].artist+"'>"+
"<input type='hidden' name='source_url' value='"+val.sources[0].src+"'>"+
"<input type='hidden' name='credits' value='"+val.sources[0].credits+"'>"+
"<input type='hidden' name='user' value='<?php echo $id; ?>'>"+
"<input type='hidden' name='playlists' value='<?php echo $playlist; ?>'>"+
"<button class='playlist-favorite' id='sub'><i class='fa fa-heart faa-flash animated-hover' style='color:#ff4444'></i></button>"+
"</form>"
+
<? } ?>