I'm working on a DBMS project using PHP and Javascript and having problem passing multiple parameters.
setting a variable from a table in javascript funtion.
<td><input type="Button" value="Remove" onclick="deletefn(<?php echo $row['SKU'] ?>);"></td>
<script>
function deletefn(sku){
location.assign('delete.php?prosku=' sku);
}
</script>
But if try to put 2 variables like this it doesn,t work
<td><input type="Button" value="Remove" onclick="deletefn(<?php echo $row['SKU'] ?>,<?php echo $row['Part_no'] ?>);"></td>
<script>
function deletefn(sku,part){
location.assign('delete.php?prosku=' sku);
location.assign('delete.php?partx=' part);
}
</script>
where am I doing mistake? Can someone help?
CodePudding user response:
The problem isn't with the function parameters, it's that only the first location.replace()
has any effect, since it redirects and the JavaScript on this page stops running.
Assuming delete.php
accepts multiple parameters, put them both in the same URL.
function deletefn(sku,part){
location.assign(`delete.php?prosku=${sku}&partx=${part}`);
}