Hi,
I’m trying to create a popup window with a form where you can edit content in a grid. I’ve used the following code to create the window and form, and it works great.
[code]var popupWindow1e = dhxLayout.dhxWins.createWindow(“editContacts”,50,50, 735, 670);
dhxLayout.dhxWins.window(“editContacts”).centerOnScreen();
dhxLayout.dhxWins.window(“editContacts”).setText(“Edit Contact”);
dhxLayout.dhxWins.window(“editContacts”).button(“park”).hide();
dhxLayout.dhxWins.window(“editContacts”).button(“minmax1”).hide();
form1e = dhxLayout.dhxWins.window("editContacts").attachForm();
form1e.loadStruct("edit_contacts.php", "json", function(){
form1e.setFocusOnFirstActive();
});[/code]
However, I want the form to open with the current data already filled in so you just edit what’s needed. I’ve set up my php document to echo the json code for the form with the value set for php variables, like so:
$subject=$row['Subject'];
echo "{type: 'input', name: 'subject', value: '$subject',label:'Subject'},";
And then I’ve written the following function to be called when the “edit” button is clicked (before the popup window is created).
[code]function editRow_contacts(str){
if (str=="")
{
document.getElementById("editContacts").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.getElementsById("editContacts").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","edit_contacts.php?q="+str,true);
xmlhttp.send();
}[/code]
The form structure loads correctly, but the data does not. I think the problem is in the document.getElementById(). What should I use for the html Id of the dhtmlx window instance? I’m able to call it to a standard html div, so I know the php document is working.
Let me know if this doesn’t make sense and I’ll try to put together a more complete demo. Basically, I just need a way to find/set an accessible ID for a dhx window.
Thanks for your help!