By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,101 Members | 1,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,101 IT Pros & Developers. It's quick & easy.

IE events on the fly

P: n/a
Cy
This works wonderfully in Firefox, but when it runs for the first time
in IE it only creates the field, but won't create any attributes for
the events. When debugging the events are null. How can I get this
to work in IE.

The table that looks like this

<table width="100%" border="1" cellpadding="0" cellspacing="2">
<tbody id="linkedTable">
<tr>
<td class="content">1) </td>
<td><input type="text" name="linked_form[]" id="linked_form1"
onKeyUp="cellHilite('linked', 'form'); addInputField('linkedTable',
'linked_form', '1', '90')" onBlur="cellHiliteOff()" size="90"></td>
</tr>
</tbody>
</table>

My script is like this
var fieldNum = 0;
function addInputField(tagID, fieldName, num, length) {
var newNum = 1+parseInt(num);
var funcText = "addInputField('" + tagID + "','" +
fieldName + "','" + newNum + "','" + length + "')"

if (document.getElementById(fieldName+num).value != '') {
row = document.createElement('TR');
cell = document.createElement('TD');
cell.setAttribute("class", 'content');
cell2 = document.createElement('TD');
cell2.setAttribute("class", 'content');
txt = document.createTextNode(newNum + ') ');
field_input = document.createElement('INPUT');
field_input.setAttribute("type", 'text');
field_input.setAttribute("id", fieldName + newNum);
field_input.setAttribute("name", fieldName+"[]");
field_input.setAttribute("size", length);
field_input.setAttribute("onKeyUp",
"cellHilite('linked', 'form'); "+funcText);
field_input.setAttribute("onMouseUp",
"cellHilite('linked', 'form'); "+funcText);
field_input.setAttribute("onBlur", "cellHiliteOff()");

if (fieldNum != num) {
document.getElementById(tagID).appendChild(row);
row.appendChild(cell);
cell.appendChild(txt);
row.appendChild(cell2);
cell2.appendChild(field_input);
}
fieldNum = num;
}
}


I had done this before, but without a table. The inputs were placed
on top of each other in a div tag. That code looks like this.
function addURLField(num) {
if
(document.getElementById('request_form')['url_'+num].value != '') {
url_input = document.createElement('INPUT');
url_input.setAttribute("type", 'text');
url_input.setAttribute("name", 'url[]');
url_input.setAttribute("id", 'url_'+ (1+parseInt(num)));
url_input.setAttribute("size", '127');
url_input.setAttribute("onKeyUp", "addURLField(\'" + (1+parseInt(num))
+ "\')");
url_input.setAttribute("onMouseUp", "addURLField(\'" +
(1+parseInt(num)) + "\')");
bold_tag = document.createElement("B");
numb = document.createTextNode((1+parseInt(num))+")-");
bold_tag.appendChild(numb);

if (probURLnumKeep != num) {
br_tag2 = document.createElement('BR');
document.getElementById('new_page_toggle').appendC hild(bold_tag);
document.getElementById('new_page_toggle').appendC hild(url_input);
document.getElementById('new_page_toggle').appendC hild(br_tag2);
}
probURLnumKeep = num;
}

}

Any help would be appreciated
Jan 12 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

Cy wrote:
field_input.setAttribute("type", 'text');
field_input.setAttribute("id", fieldName + newNum);
field_input.setAttribute("name", fieldName+"[]");
field_input.setAttribute("size", length);
The setAttribute function does not work correctly in IE. Do this
instead:

field_input.type = "text";
field_input.id = fieldName + newNum;
field_input.name = fieldName + "[]";
field_input.size = length;
field_input.setAttribute("onKeyUp",
"cellHilite('linked', 'form'); "+funcText);
field_input.setAttribute("onMouseUp",
"cellHilite('linked', 'form'); "+funcText);
field_input.setAttribute("onBlur", "cellHiliteOff()");


Events are a different matter. You should be using addEventListener
and attachEvent (IE) methods. Please look them up on how to use them.

Jan 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.