Reputation: 163
Hi i want to send data from php code to java script and java script code send themes to another php file like below:
<td><input type="submit" value="Edit" name="edit" id="edit" onclick="sendToEdit(<?php echo $row['pID'] ?>,<?php echo $row['phID']?>,<?php echo $testHistoryDate ?>,<?php echo (string)$type ?>);" />
when i debug with firebug i see php code make true values in the php area but when send themes to java script can't send <?php echo $testHistoryDate ?>,<?php echo (string)$type ?>);
true values and send another date for testHistoryDate and true value for (string)$type
but fire bug make below error:
Phibrinozhen is not defined
[Break On This Error]
sendToEdit(9004, 119002, 1997, Phibrinozhen);
in the above code 1997 isn't true value true value is:
onclick="sendToEdit(9004,119002,2010-10-03,Phibrinozhen);"
that php make but java script java script code
function sendToEdit(pID,phID,thDate,type)
Upvotes: 0
Views: 157
Reputation: 15338
<td><input type="submit" value="Edit" name="edit" id="edit" onclick="sendToEdit('<?php echo $row['pID'] ?>','<?php echo $row['phID']?>','<?php echo $testHistoryDate ?>','<?php echo (string)$type ?>');" />
Upvotes: 2
Reputation: 499
The error is occurring because you trying to pass string literals without telling JavaScript they are strings. You need to escape at least your final two parameters with quotes: '2010-10-0', 'Phibrinozhen'
.
Upvotes: 3