leatherback
Technical User
Dear All,
My first post here. Hope you guys can help me. I am banging my head against the wall over this problem..
I am trying to create a way to insert a set of 3 (name, volume, units) new textfields into my form whenever the user needs one. (This will be triggered by an onchange() in the second-last available textfield).
In itself this works. However, somehow IE seems incapable of then finding the field, when I try to retrieve the value in that field. I had it working fine in FF, but IE killed it.
I work by copying a hidden div into the form, like so (Note that only the main js are included, and that I am flip-flopping between using ID and NAME tags):
function moreFields() {
counter++;
var newFields = document.getElementById('ingredientroot').cloneNode(true);
newFields.id = '';
newFields.style.display = 'block';
var newField = newFields.childNodes;
for (var i=0;i<newField.length;i++) {
var theName = newField.name
if (theName)
//newField.name = theName + counter;
newField.ID = theName + counter;
}
var insertHere = document.getElementById('writeroot');
insertHere.parentNode.insertBefore(newFields,insertHere);
}
This function is succesfully called like this: <input type=\"text\" name=\"amount\" onchange=\"javascript:moreFields(); \" />
Subsequently, I am using another formfield to retrieve data suggestions from the database; For this I am modifying an XML suggest search box. The script I am working on is:
function searchSuggest(ScriptName, TheId) {
window.myValue = TheId;
if (searchReq.readyState == 4 || searchReq.readyState == 0) {
str = escape(document.getElementById(TheId).value);
searchReq.open("GET", ScriptName+'?search=' + str, true);
searchReq.onreadystatechange = handleSearchSuggest;
searchReq.send(null);
}
}
This script is succesfuly called like this: <input type=\"text\" name=\"ingredientn\" id=\"ingredients\" onkeyup=\"searchSuggest('".$ingredientSuggest."', this.id);\" autocomplete=\"off\"/>
The line: str = escape(document.getElementById(TheId).value);
is the real killer at the moment.
If somebody has something along these lines, or can help me sort this out.. Great!
Cheers,
Jelle.
My first post here. Hope you guys can help me. I am banging my head against the wall over this problem..
I am trying to create a way to insert a set of 3 (name, volume, units) new textfields into my form whenever the user needs one. (This will be triggered by an onchange() in the second-last available textfield).
In itself this works. However, somehow IE seems incapable of then finding the field, when I try to retrieve the value in that field. I had it working fine in FF, but IE killed it.
I work by copying a hidden div into the form, like so (Note that only the main js are included, and that I am flip-flopping between using ID and NAME tags):
function moreFields() {
counter++;
var newFields = document.getElementById('ingredientroot').cloneNode(true);
newFields.id = '';
newFields.style.display = 'block';
var newField = newFields.childNodes;
for (var i=0;i<newField.length;i++) {
var theName = newField.name
if (theName)
//newField.name = theName + counter;
newField.ID = theName + counter;
}
var insertHere = document.getElementById('writeroot');
insertHere.parentNode.insertBefore(newFields,insertHere);
}
This function is succesfully called like this: <input type=\"text\" name=\"amount\" onchange=\"javascript:moreFields(); \" />
Subsequently, I am using another formfield to retrieve data suggestions from the database; For this I am modifying an XML suggest search box. The script I am working on is:
function searchSuggest(ScriptName, TheId) {
window.myValue = TheId;
if (searchReq.readyState == 4 || searchReq.readyState == 0) {
str = escape(document.getElementById(TheId).value);
searchReq.open("GET", ScriptName+'?search=' + str, true);
searchReq.onreadystatechange = handleSearchSuggest;
searchReq.send(null);
}
}
This script is succesfuly called like this: <input type=\"text\" name=\"ingredientn\" id=\"ingredients\" onkeyup=\"searchSuggest('".$ingredientSuggest."', this.id);\" autocomplete=\"off\"/>
The line: str = escape(document.getElementById(TheId).value);
is the real killer at the moment.
If somebody has something along these lines, or can help me sort this out.. Great!
Cheers,
Jelle.