Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
134
rated 0 times [  139] [ 5]  / answers: 1 / hits: 8184  / 10 Years ago, thu, september 4, 2014, 12:00:00

Hi i am using php where i am using ajax i am retrieving data from database without reloading page i am getting data on same page now i want that when i get data i retrieve in table format then there is update button there when i click on update button a new form should open



Here is code



index.php



<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=Content-Type content=text/html; charset=utf-8 />
<title>Untitled Document</title>
<script type=text/javascript>
function fun()
{
var exam=new XMLHttpRequest();
exam.onreadystatechange=function()
{
if(exam.readyState==4)
{
document.getElementById(res).innerHTML=exam.responseText;
}
}
exam.open(GET,rat_test.php?name=pramod,true);
exam.send(null);
}
</script>
</head>
<body>
<form action= method=post id=form name=form>
<table>
<tr>
<td></td><td><input type=button onclick=fun(); value=getvalue />
</td></tr>
<div id=res></div>
</table>
</form>
</body>
</html>


rat_test.php



<table  border=1>
<tr>
<th scope=col>ID</th>
<th scope=col>Name</th>
</tr>
<?php
include(connection.php);
$sel=select * from info;
$res=mysql_query($sel);
while($fet=mysql_fetch_array($res))
{ ?>
<tr>
<td><input type=checkbox name=users[] value=<?php echo $row[id]; ?> ></td>
<td><?php echo $fet['id']; ?></td>
<td><?php echo $fet['name']; ?></td>

</tr>
<?php }
?>
</table>
<form action= method=post id=form name=form>
<table>
<tr>
<td></td><td><input type=button onclick=fun()1; value=Update />
</td></tr>
</table>
</form>


here in test_rat.php a update button is available i want to open a new form on that update button button



How can i achieve this



Any help will be appreciated


More From » php

 Answers
19

You have not clearly mention what you want here ..



As i understand, you want open a form on click of update button to open a form



i did same ....



Just you need to update rat_test.php with below code...



<table  border=1>
<tr>
<th scope=col>ID</th>
<th scope=col>Name</th>
</tr>
<?php
include(connection.php);
$sel=select * from info;
$res=mysql_query($sel);
while($fet=mysql_fetch_array($res))
{ ?>
<tr>
<td><input type=checkbox name=users[] value=<?php echo $row[id]; ?> ></td>
<td><?php echo $fet['id']; ?></td>
<td><?php echo $fet['name']; ?></td>

</tr>
<?php }
?>
</table>

<table>
<tr>
<td></td><td><input type=button onclick=document.getElementById('updateForm').style.display='block' value=Update />
</td></tr>
</table>
<div id=updateForm style=display:none>
<form action= method=post id=form name=form>
<table border=1>
<tr>
<th scope=col>ID</th>
<th scope=col><input type=text></th>

<tr>
<th scope=col>Name</th>
<th scope=col><input type=text></th>
</tr></tr>
</form></div>


If you need more help ..please elaborate your requirement...


[#42713] Wednesday, September 3, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hugo

Total Points: 21
Total Questions: 120
Total Answers: 107

Location: Belarus
Member since Tue, Jul 20, 2021
3 Years ago
;