Code: Select all
<input type='submit' value='Remove listing' name='$a1[car_listing_ID]' />Thanks in advance
Moderator: General Moderators
Code: Select all
<input type='submit' value='Remove listing' name='$a1[car_listing_ID]' />Code: Select all
<input type='hidden' value='' name='id'>
<input type='submit' value='Remove listing' name='$a1[car_listing_ID]' onClick='thisfunction($a1[car_listing_ID]);'/>
Hi I got it working I realised The if statement to get the id of the button was outside the while loop thanksEducatedFool wrote:maybe by using JavaScript.
Write a javascript function 'thisfunction' where you put the value of the button in the hidden field. If you submit your form you can get the value from the hidden field 'id'.Code: Select all
<input type='hidden' value='' name='id'> <input type='submit' value='Remove listing' name='$a1[car_listing_ID]' onClick='thisfunction($a1[car_listing_ID]);'/>
Code: Select all
//whatever you do to start the loop
{
if ($_POST[$a1[car_listing_ID]] == "Remove listing") {
//Remove listing
}
}
Hi, Thats exactly more or less what i did lolonion2k wrote:Don't use Javascript for something as important as that. Not all users have it switched on.
Perform the same loop as you do to output the button HTML, and check if the button was pressed for each record..
Code: Select all
//whatever you do to start the loop { if ($_POST[$a1[car_listing_ID]] == "Remove listing") { //Remove listing } }
Code: Select all
if (isset($_POST[$adid]))
{
$clickedremove = $_POST[$adid];
$_POST[error] = "Are you sure you want to delete <br/> ";
$deletebutton = "<input type=\"submit\" value=\"Yes\" name=\"yesdel\" />
<input type=\"submit\" value=\"No\" name=\"nodel\" />";
}
if (isset($_POST['yesdel']))
{
$reallydelete ="true";
$deletebutton = "";
} elseif (isset($_POST['nodel'])) {
$reallydelete = "false";
$deletebutton = "";
}you need to echo this line with "" 's or echo that name variable.<input type='submit' value='Remove listing' name='$a1[car_listing_ID]' />
I wonder how you even test your scripts.. No offence..Code: Select all
# if (isset($_POST[$adid])) //Here again you're missing ' ' # { # $clickedremove = $_POST[$adid]; //And here... # $_POST[error] = "Are you sure you want to delete <br/> "; //And here... # $deletebutton = "<input type=\"submit\" value=\"Yes\" name=\"yesdel\" /> # <input type=\"submit\" value=\"No\" name=\"nodel\" />";
Hi maybe I should have mentioned it butdesmi wrote:Not completely related, but by seeing your other posts/topics, you really should learn some more basics.
I can see far too many error that will confuse you while testing you script.. eg:
you need to echo this line with "" 's or echo that name variable.<input type='submit' value='Remove listing' name='$a1[car_listing_ID]' />
I wonder how you even test your scripts.. No offence..Code: Select all
# if (isset($_POST[$adid])) //Here again you're missing ' ' # { # $clickedremove = $_POST[$adid]; //And here... # $_POST[error] = "Are you sure you want to delete <br/> "; //And here... # $deletebutton = "<input type=\"submit\" value=\"Yes\" name=\"yesdel\" /> # <input type=\"submit\" value=\"No\" name=\"nodel\" />";
ravx wrote:I want a message saying are you sure you want to delete and a yes and no option.
Code: Select all
<form onsubmit="return confirm('Are you sure you want to do this?');">