Hello there, I have a problem and the only thing I have not done is yell 4 help.....
I have a main window which opens a popup(window), before opening the window I create a javascript object, just communicate the window-popup, in the popup, I'm creating some "hidden fields" in the fly and append them to it's parent, a <input type=hidden name=something> everything works great, the fields are created, then the popup closes, still ok.....then if the user wants to go and modify any of the fields in the popup, then I open the popup, populate all the fields in the popup from the hidden fields, then remove the hidden fields.....works great, after the user enters the new data I "re-create the hidden fields" again w/the new data, this is just for avoiding duplicity.....
so...everything works. gooooood....but....my friends, when the form(in the main window) is sent to the server, I store all those fields in the database....great...still ok...the problem is when I want to show that information back to the user...(a report view, or report Edit....) so I read the db, recreate the hidden fields and put them in the form same format, same parent, same name, same Id.....same values...when the form gets to the client, still everything ok, BUT.. when the user clicks in the area that opens the popup, the popup opens, populates all the form fields..FROM THE HIDDEN FIELDS, THEN TRIES TO DELETE THE HIDDEN FIELDS, THAT'S WHEN I'M HAVING THE PROBLEM.......
....I'm gettin a "Invalid argument" I checked the logic "same one that deleted the fields before", I displayed the value, id, name of the "parameter to the removeChild method" and everything looks good.........
don't know what else to do... Next is the logic that creates the fields, and the logic that removes them....Just one more comment, there are some fields w/the same name but diff. Id. and some w/the same id but diff. name....still, the logic works when they "are created in the fly" but not when I create them in the server, before sending the form out to the client............an example to this can be found in www.ex-isb.com, then click the link, user/pwd is helper/helper thanks.......................
again please remember that the problems occurs when I create the hidden fields in the server..........don't know if this can be the prob.. or not....what tha hell, i know nothing now.......
those commented lines are just for debbuging
function addHiddenField(name, id, value)
{
var holderField = document.getElementById("tmpFieldHolder");
tmpField = document.createElement("input");
tmpField.setAttribute("type","hidden");
tmpField.setAttribute("name",name);
tmpField.setAttribute("value",value);
tmpField.setAttribute("id", id);
holderField.appendChild(tmpField);
//alert("Field added:" + name + "\nId:" + id + "\nvalue:" + value);
}
function removeHiddenField(dayToRemove)
{
var parent = document.getElementById("tmpFieldHolder");
var tempChilds = parent.all.tags("input");
var tempObject;
var fieldPrefixName;
var allFields = "ALL";
var objById;
//transverse all the childs and find the ones to delete
var lengthOfChilds = tempChilds.length;
// for(i=0;i<tempChilds.length;i++)
// {
// alert("fieldto be removed:"+tempChilds[i].name+"\nid:"+tempChilds[i].id+"\nvalue:"+tempChilds[i].value);
// }
for(idx=0;idx<lengthOfChilds;idx++)
{
tempObject = tempChilds[idx];
fieldPrefixName = tempObject.name.substr(0,3);
if(fieldPrefixName == dayToRemove)
{
//try
//{
//objById = getElementById(tempObject.id);
parent.removeChild(tempObject);
tempChilds = parent.all.tags("input");
//}
//catch(x)
//{
// alert(x)
//tempChilds = parent.all.tags("input");
//}
}
if(allFields == dayToRemove)
{
parent.removeChild(tempObject);
tempChilds = parent.all.tags("input");
}
}
}
I have a main window which opens a popup(window), before opening the window I create a javascript object, just communicate the window-popup, in the popup, I'm creating some "hidden fields" in the fly and append them to it's parent, a <input type=hidden name=something> everything works great, the fields are created, then the popup closes, still ok.....then if the user wants to go and modify any of the fields in the popup, then I open the popup, populate all the fields in the popup from the hidden fields, then remove the hidden fields.....works great, after the user enters the new data I "re-create the hidden fields" again w/the new data, this is just for avoiding duplicity.....
so...everything works. gooooood....but....my friends, when the form(in the main window) is sent to the server, I store all those fields in the database....great...still ok...the problem is when I want to show that information back to the user...(a report view, or report Edit....) so I read the db, recreate the hidden fields and put them in the form same format, same parent, same name, same Id.....same values...when the form gets to the client, still everything ok, BUT.. when the user clicks in the area that opens the popup, the popup opens, populates all the form fields..FROM THE HIDDEN FIELDS, THEN TRIES TO DELETE THE HIDDEN FIELDS, THAT'S WHEN I'M HAVING THE PROBLEM.......


again please remember that the problems occurs when I create the hidden fields in the server..........don't know if this can be the prob.. or not....what tha hell, i know nothing now.......
those commented lines are just for debbuging
function addHiddenField(name, id, value)
{
var holderField = document.getElementById("tmpFieldHolder");
tmpField = document.createElement("input");
tmpField.setAttribute("type","hidden");
tmpField.setAttribute("name",name);
tmpField.setAttribute("value",value);
tmpField.setAttribute("id", id);
holderField.appendChild(tmpField);
//alert("Field added:" + name + "\nId:" + id + "\nvalue:" + value);
}
function removeHiddenField(dayToRemove)
{
var parent = document.getElementById("tmpFieldHolder");
var tempChilds = parent.all.tags("input");
var tempObject;
var fieldPrefixName;
var allFields = "ALL";
var objById;
//transverse all the childs and find the ones to delete
var lengthOfChilds = tempChilds.length;
// for(i=0;i<tempChilds.length;i++)
// {
// alert("fieldto be removed:"+tempChilds[i].name+"\nid:"+tempChilds[i].id+"\nvalue:"+tempChilds[i].value);
// }
for(idx=0;idx<lengthOfChilds;idx++)
{
tempObject = tempChilds[idx];
fieldPrefixName = tempObject.name.substr(0,3);
if(fieldPrefixName == dayToRemove)
{
//try
//{
//objById = getElementById(tempObject.id);
parent.removeChild(tempObject);
tempChilds = parent.all.tags("input");
//}
//catch(x)
//{
// alert(x)
//tempChilds = parent.all.tags("input");
//}
}
if(allFields == dayToRemove)
{
parent.removeChild(tempObject);
tempChilds = parent.all.tags("input");
}
}
}
Comment