• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need Help using submit button onclick in PHP

faisal83

Junior Member
How to pass the value using onclick button??

<?php $book_id = $_SESSION['book_id'];
$query = "SELECT * FROM books WHERE book_id = '$book_id'" ;
$result = mysql_query($query);
$numrows = mysql_num_rows($result);

if($numrows==0){
echo "<script>alert('No record for $book_id');</script>";
}

if($numrows!=0){

?>

<form action="returnsearch.php" method="post" name="form">
<table border="1" width="96%">
<tr bgcolor="#E9AB17">
<td width="12%"><div align="center">NO. RECORD ID</div></td>
<td width="13%"><div align="center" >NO. BOOK ID</div></td>
<td width="53%"><div align="center" >TITLE</div></td>
<td width="22%"><div align="center" >ACTION</div></td>
</tr>
<?php while($row = mysql_fetch_array($result)){ ;?>
<tr>
<td height="26"><div align="center" ><?php echo $row['no_id']; ?></div></td>
<td height="26"><div align="center" ><?php echo $row['book_id']; ?></div></td>
<td height="26"><div align="center" ><?php echo $row['title']; ?></div></td>
<td height="26"><div align="center"><input type="button" name="submit" value="Hantar" onClick="????">
</div></td></tr>

?>
 
Can you explain a little more what you are trying to do?

Is this the code from "returnsearch.php"?

In the past, when displaying rows of data that I wanted to show details on, I've used links that were built on the fly instead of buttons. I have used images so it looked like a button, but it really was just a link or I've made the ID number into a link that calls the details page...

href="returnsearch.php?id=1"
href="returnsearch.php?id=2"
. . .

Then in the returnsearch.php page I use the $_GET['id'] to get the number they selected.

I don't know if that's what you are trying to accomplish or not or if there are other reasons you are trying to use the on-click.
 
Back
Top