0

hi all,
i had a php page.i am using ajax for displaying a table.
When i select a date images uploaded on that date gets displayed in a table.This is working fine.But i need another button for edit.so when i click on edit those images present in table should become editable.
(OR)
i am passsing a date value through url in line25. so can we pass button value also in the same url(which is in line53)...????

<html>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","useajax.php?q="+str,true);
xmlhttp.send();
}

</script>
<head>
<link rel="stylesheet" type="text/css" href="css/table.css"/>
<meta charset="UTF-8" />
    <link rel="stylesheet" href="css/base.css" type="text/css" media="all" />
    <link type="text/css" href="css/jquery.ui.all.css" rel="stylesheet" />
    <script type="text/javascript" src="jquery-1.4.2.js"></script>
    <script type="text/javascript" src="ui/jquery.ui.core.js"></script>
    <script type="text/javascript" src="ui/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="ui/jquery.ui.datepicker.js"></script>
    <link type="text/css" href="css/demos.css" rel="stylesheet" />
    <script type="text/javascript">
    $(function() {
        $("#datepicker").datepicker();
    });
    </script>
</head>
<body>
<form action="imageslist.php" method="post">
<table align="right"> 
    <tr> <td></td>
        <td></td><td><a href="logout.php"><h2>Logout</h2></a></td></table>
<div class="demo" align="left">
<h2>Choose Uploaded date <input name="dates" type="text" id="datepicker" onchange="showUser(this.value)">
<input type="button" name="edit" value="Assign" id="edit" style="background-color:#A7C942; color:#ffffff; font-size: 1.2em;" onclick="showUser(this.value)"></h2>
</div>
<br>
<div align="center" id="txtHint"><h1>Images information will be listed here.</h1></div>
<table align="center"><tr><td>  
</table> 
</form>
</body>
</html>
2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by niths
0

You can use an extra parameter in your showUser() javascript function and pass the type of operation as the second parameter,
e.g.
Change the function as,

....
function showUser(str, op){
....

Modify all call to showUser as

<input type="button" name="edit" value="Assign" id="edit" style="background-color:#A7C942; color:#ffffff; font-size: 1.2em;" onclick="showUser(this.value, 'edit')">

and so on.

Now in the showUser() function at line 25 pass both the str and op as

xmlhttp.open("GET","useajax.php?q="+str+"&op="+op,true);

and in useajax.php you can read both the str and op
Hope this was helpful

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.