I am trying to redirect my page to a location (addparty.php?edit=true&id=1
) with a button click. I am using JavaScript for a static value. Here is the code:
Here is my PHP code and JavaScript function.
$result=mysql_query("SELECT * FROM party ORDER BY partyName");
echo mysql_error();
while($note = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><label>$note[partyId]</label></td>";
echo "<td><label>$note[partyName]</label></td>";
echo "<td><label>$note[partyAddress]</label></td>";
echo "<td><label>$note[partyBankAcc]</label></td>";
echo "<td><label>$note[partyBankName]</label></td>";
echo "<td><label>$note[partyRTGSCode]</label></td>";
echo "<td><label>$note[partyEmail]</label></td>";
echo '<td><button name="change" id="change" value="$note[partyId]"
onClick="check();">Edit</button>
echo "</tr>";
}
Javascript code:
function check()
{
window.location.href="addparty.php?edit=true&id=1";
}
Here I am getting all the values from party table. I want to got to addparty.php?edit=true&id=$note[partyId]
.If you see the onClick
event it calls check()
function. Now my id=1
is static and it works, but I want that id=$note[partyId]
(which is unique party id of each party).
Any suggestions? Thanks in advance.
I am trying to redirect my page to a location (addparty.php?edit=true&id=1
) with a button click. I am using JavaScript for a static value. Here is the code:
Here is my PHP code and JavaScript function.
$result=mysql_query("SELECT * FROM party ORDER BY partyName");
echo mysql_error();
while($note = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><label>$note[partyId]</label></td>";
echo "<td><label>$note[partyName]</label></td>";
echo "<td><label>$note[partyAddress]</label></td>";
echo "<td><label>$note[partyBankAcc]</label></td>";
echo "<td><label>$note[partyBankName]</label></td>";
echo "<td><label>$note[partyRTGSCode]</label></td>";
echo "<td><label>$note[partyEmail]</label></td>";
echo '<td><button name="change" id="change" value="$note[partyId]"
onClick="check();">Edit</button>
echo "</tr>";
}
Javascript code:
function check()
{
window.location.href="addparty.php?edit=true&id=1";
}
Here I am getting all the values from party table. I want to got to addparty.php?edit=true&id=$note[partyId]
.If you see the onClick
event it calls check()
function. Now my id=1
is static and it works, but I want that id=$note[partyId]
(which is unique party id of each party).
Any suggestions? Thanks in advance.
Share Improve this question edited Feb 8, 2019 at 13:04 Sofyan Thayf 1,3282 gold badges15 silver badges26 bronze badges asked Mar 29, 2013 at 18:06 ashah142ashah142 5801 gold badge5 silver badges12 bronze badges2 Answers
Reset to default 4Change the button to this:
echo '<td><button name="change" id="change" onClick="check(' . $note['partyId'].');">Edit</button>';
Change javascript to this:
function check(id)
{
window.location.href="addparty.php?edit=true&id=" + id;
}
Try adding $note[partyId]
as a parameter to your check()
-
function check(partyId)
{
window.location.href="addparty.php?edit=true&id="+partyid;
}
and
echo '<td><button name="change" id="change" onClick="check('.$note['partyId'].');">Edit</button>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745205425a4616571.html
评论列表(0条)