I am using PHP to generate 10 forms on a page which attach an image as the button and POST hidden values to a _blank target. This works ok in Firefox, all 10 buttons submit and post to a new window. In Safari however only the first button i click will work (whichever one I choose) after that none of the buttons (forms) submit and POST to a new window (!!! whats going on??)
Heres the code –
$id=getId();
echo "<form name=\"clickthrough$id\" action=\"click_through.php\" method=\"POST\" target=\"_blank\"><input type=\"image\" src=\"images/buttons/buynow_a.gif\" name=\"buynow\"/><input type=\"hidden\" name=\"id\" value=\"".$id."\"/></form>";
Nothing strange here – the id is actually the id of a song in my database which i have simplified for showing here – but I included it on the end of the form name just incase this was causing the problem.
So to recap I end up with 10 buy now buttons on a page – all of which should post through to a PHP script. The scripts work fine. However in safari once i have pressed any buy now button all of the others stop working (until I refresh the page)
why is this?
— here is the final html that is generated for the buttons
<form name="clickthrough1728" action="click_through.php" method="POST" target="_blank"><input type="image" src="images/buttons/buynow_a.gif" name="buynow"/><input type="hidden" name="id" value="1728"/><input type="hidden" name="location" value="UK"/></form>
<form name="clickthrough1724" action="click_through.php" method="POST" target="_blank"><input type="image" src="images/buttons/buynow_a.gif" name="buynow"/><input type="hidden" name="id" value="1724"/><input type="hidden" name="location" value="UK"/></form>
<form name="clickthrough1718" action="click_through.php" method="POST" target="_blank"><input type="image" src="images/buttons/buynow_a.gif" name="buynow"/><input type="hidden" name="id" value="1718"/><input type="hidden" name="location" value="UK"/></form>
….
I have just tried copying this to a new html file and testing and the same thing happens – the first click will open a new window but no buttons after that will post the form
A Quick check with the following code works just fine
(Safari 5 on Mac)
so it could be your
$id. Generate the html and show it like Pekka suggestedEdit
I can’t tell you what goes wrong in safari-windows-land
but i’ve changed the code as follows an tested it on a VM (Win XP, Safari5) and it works:
every form got its “unique” action target
?$idand this seams to do the trickEdit Link and Files removed