ASM wrote:
> IE would prefer :
> textarea.name = "inputDialog";
> textarea.id = "inputDialog";
Ok, I have changed this in my code. Thanks
I'd just like to point out that I don't have access to Internet
Explorer, so I am using Firefox. As far as I know it shouldn't be a big
issue, but I know some things are different between the way that
Internet Explorer and Firefox process JavaScript, or rather the syntax
and attributes which should be used.
> why do you append something to your td not more there ?
Sorry, I don't understand what you mean. Are you suggesting I use
innerHTML instead of appending textarea?
> td.appendChild(textarea); // from inside
> tr.appendChild(td); // to outside
> table.appendChild(tr); // boxes
Ok, I have changed my code to reflect this. It makes more sense doing
it the way you suggested, although I was simply going by the examples
by Mark Kahn at
http://www.htmlgoodies.com/primers/j...le.php/3594621
> Same as I previously said : better to append in right order
Agreed, and already done.
> p or span -> td -> tr -> tbody -> table -> body
There are no body tags in my HTML. Would this make any difference as
everything goes inside my <tbody>? Everything is displaying correctly,
it's just this single function that is refusing to fire.
> perhaps :
> titleSpan.onclick = function()
I have tried just doing:
titleSpan.onClick = function() { alert('blah'); }
....and it still won't fire...
> a question : is this table in a form ?
No, I'm not, and I don't plan to either.
Here is the code modified following your suggestions. I have included
the HTML also, in case I have made a stupid mistake.
//***** CODE START *****
> /*************
> * HTML code *
> ************/
> <head>
> <title>Colour Text Generator</title>
> </head>
> <table style="width: 100%;">
> <tbody id="ctg_table">
> </tbody>
> </table>
> <script language="javascript" type="text/javascript" src="text_generator.js"></script>
> <noscript>
> You must enabled JavaScript in order to use this page.<br /><br />
> If you do not have a JavaScript enabled browser, please download Firefox
> for free from <a href="http://www.getfirefox.com">www.getfirefox.com</a>.
> </noscript>
> //******************
> * JavaScript code *
> ******************/
> var tbody = document.getElementById('ctg_table');
> var tableWidth = 80;
> var row1 = null;
> function initPage()
> {
> tbody.parentNode.style.width = tableWidth + "%";
> displayInputDialog();
> row1 = new menuItem("test");
> }
> function displayInputDialog()
> {
> var tr = document.createElement('tr');
> tr.setAttribute("id", "rInputDialog");
> tr.style.height = "20%";
> var td = document.createElement('td');
> var textarea = document.createElement('textarea');
> textarea.name = "inputDialog";
> textarea.id = "inputDialog";
> textarea.style.width = "100%";
> textarea.style.height = "100%";
> textarea.style.borderStyle = "ridge";
> td.appendChild(textarea);
> tr.appendChild(td);
> tbody.appendChild(tr);
> }
> function menuItem (menuTitle)
> {
> var tr1 = document.createElement('tr');
> tr1.style.backgroundColor = "blue";
> var td1 = document.createElement('td');
> var titleSpan = document.createElement('span');
> titleSpan.style.color = "white";
> titleSpan.style.fontWeight = "bold";
> titleSpan.onClick = function() { alert('blah'); }
> titleSpan.innerHTML = menuTitle;
> td1.appendChild(titleSpan);
> tr1.appendChild(td1);
> tbody.appendChild(tr1);
> var tr2 = document.createElement('tr');
> var td2 = document.createElement('td');
> td2.innerHTML = 'blah';
> tr2.appendChild(td2);
> tbody.appendChild(tr2);
> }
> initPage();
//****** CODE END ******
Many thanks.
Daz.