Microsoft
Software
Hardware
Network
Question : Dynamically adding javascript with createElement('script')
I have this code below where I'm dynamically adding rows to a table...
I have 9 cells from 0 - 8.
This code works up to a point with no errors:
This is where it somewhat fails: //Set the javascript for the Combo Box :: See Below.
After the dynamic creation of the combo box I need to have the following script added to CELL 5 in the table, row after new row.
<script>
var z=dhtmlXComboFromSelect("c
mStds");
</script>
That's it.
//Standard Select Box
var cellStandard = row.insertCell(5);
var celS = document.createElement('se
lect');
celS.name = 'standard' + iteration;
celS.id = 'standard' + iteration;
celS.size = 1;
celS.style.fontSize = '10px';
cellStandard.appendChild(c
elS);
var option = document.createElement('op
tion');
option.value = '0';
option.appendChild(documen
t.createTe
xtNode("Se
lect One"));
celS.appendChild(option);
<% while (!cmStd.EOF) { %>
var option = document.createElement('op
tion');
option.value = '<%=(cmStd.Fields.Item("cm
_std_id").
Value)%>';
option.appendChild(documen
t.createTe
xtNode('<%
=(cmStd.Fi
elds.Item(
"cm_stand_
txt").Valu
e)%>'));
celS.appendChild(option);
<% cmStd.MoveNext(); } if (cmStd.CursorType > 0) { if (!cmStd.BOF) projs.MoveFirst(); } else { cmStd.Requery(); } %>
//Set the javascript for the Combo Box - THIS IS WHAT'S NOT WORKING!
var ss = document.createElement('sc
ript');
ss.type = 'text/javascript';
ss.language = 'javascript';
ss.text = "var z = dhtmlXComboFromSelect('cmS
tds" + iteration + "');";
ss.defer = true;
var tt = document.createTextNode(ss
);
cellStandard.appendChild(t
t);
Instead of the script being written I get this:
[object HTMLScriptElement]
I just need to dynamically write this:
<script>
var z=dhtmlXComboFromSelect("c
mStds");
</script>
Every time I add a new row. that's pretty much it.
Peter
Answer : Dynamically adding javascript with createElement('script')
... and you removed the createTextNode("your code here")
Random Solutions
how long will deleted table hold values
Word background image problem
Is there a funtion that if I use substr(col,1,1) will tell me where a value is not a character
EIGRP Feasibility Condition
Remote Desktop Connection to Windows SBS 2008
Can't get Thumbnails to Work Outside of the Domain
Top view (2D) Battleship following the mouse cursor (with bearing and limited turning speed)
Sort columns in pivot table.
Removing rollOver and rollOut handlers on movieclips
VMWare VSphere upgrade