my query is generating 3 result with three send enquiry button which send the value of there respective hidden field but all the time when i click send enquiry button i show me always the 1st company name in my javascript
here is my php..
$adcategory=$_GET['category'];
mysql_connect('localhost','root','');
mysql_select_db('advertising site');
$selectquery="select * from business_ads where company_category='$adcategory'";
$result=mysql_query($selectquery)or die(mysql_error());
$resultrows=mysql_num_rows($result);
if($resultrows>=1)
{
echo"<p>$resultrows</p>";
while($row=mysql_fetch_array($result))
{
$companyname=$row['company_name'];?>
<div id="ads">
<p id="company_name" name="company_name"><?php echo $companyname?></p>
<input type="hidden" name="hidden_company_name" value="<?php echo
$companyname>"id="hidden_name">
<input type="hidden" name="hidden_company_name" value="<?php echo $companyname ?
>"id="hidden_name">
<center><input type="button" name="send_enquiry" id="send_enquiry" value="Send
Enquiry"
onclick="f1();"></center>
<input type="submit"value="submit" name="submit_enquiry_form">
</div>
<?php
}
}
and here is my javascript
function f1()
{
var comp_name=document.getElementById('hidden_name').value;
var elements=comp_name;
document.write(elements);
}