This string has a php echo. I must have messed something up because it seems to cause a JS error. I have tried everything I can think of to get this to work. If I take the php string out everything works. AND if I take the PHP select and place it outside the jquery string that works. I guess I just need some help combining the PHP string and the JS. (ignore the string spacing I only did that so that it is easier to read)
Thanks for any help.
$("#billTasks").find('tr').append('
<td>
<select class="billOptions">
<option class="fixedRate" onclick="fixedOption(this)">Bill Fixed Rate</option>
<option class="hourly" onclick="hourlyOption(this)">Bill Hourly</option>
</select>
<input type="text" name="fixedRate" placeholder="Rate" class="fieldWidth100 rate"/>
<select>
<?php while($row = $db->sql_fetchrow($result)){echo "<option value=\'.$row[schedule].\'> $row[schedule] </option>\n";}?>
</select>
</td>');
You have a couple issues with this line:
The first is the
.‘s You are not using string concatenation so you don’t want dots around your variable. Since it is a complex variable your code would be better like{$row[schedule]}.Secondly you need to put quotes around the string
scheduleotherwise PHP searches for a constant with that name before throwing a warning and using it as a string. So the line will end up looking like:Javascript also doesn’t like newline characters in a string unless the are written literately
\n. Meaning that you should change your\nto\\n, so that php outputs\ninstead of an actual newline character:Or use PHP single quotes and do: