dimanche 4 janvier 2015

Opening a new link using submit button not anchor tag

I need to be able to when the submit button is clicked a new tab must be open based on the anchor link coming from the database. I have been struggling for hours.


this is my form



<form action="" method="POST">

<select name="name">

<option value="">Select Names</option>
<option value="1">Names</option>
</select>
<input type ="submit" name="submit" value="find random name">

</form>


Here is the php



<?php
$query="SELECT * FROM names_table ORDER BY RAND() LIMIT 1 ";
$result=mysqli_query($connection,$query);
if(!$result){echo "no results";}
while($selected=mysqli_fetch_assoc($result)){


$link=$selected['name'];

echo $ran_name= "<a href=$link target=\"_blank\">Click here</a>";
?>


// this code works but i dont want to be able to use Click here i want to be able to generate the results once the submit button is clicked , the submit button must open the new tab.I think javascript must be used but i dont know how.





Aucun commentaire:

Enregistrer un commentaire