SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: DHTML IE error

  1. #1
    SitePoint Addict y_oda2002's Avatar
    Join Date
    May 2005
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DHTML IE error

    Hi everyone,

    I am new to using dhtml techniques...
    I have used some javascript before but not much...

    I have the following code:

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    	<head>
    	<script type="text/javascript">
    			
    			ctr = 1;
    			
    			//Current medication management/addition of nodes
    			function addCurMed()
    			{
    				//Create the necessary elements
    				var newMedTr = document.createElement('tr');
    				var newMedTd = document.createElement('td');
    				
    				//Create the medication element
    				var newMed = document.createElement('input');
    				newMed.type = "text";
    				newMed.name = "m_" + ctr;
    				newMed.maxlength = "255";
    				
    				
    				//Append inputs to the <td>
    				newMedTd.appendChild(newMed);
    				
    				//Append the td's to the tr
    				newMedTr.appendChild(newMedTd);
    				
    				//Append the tr to the document
    				document.getElementById('cMeds').appendChild(newMedTr);
    				
    				ctr++;
    			}
    		</script>
    	</head>
    <body>
    	<table cellspacing="0" cellpadding="0" class="form" id="cMeds">
    		<tr>
    			<td>
    				<input type="text" value="" name="m_0" maxlength="255">
    			</td>
    		</tr>	
    	</table>
    	<table cellspacing="0" cellpadding="0" class="form">
    		<tr>
    			<td align="center"><input type="button" onClick="addCurMed()" value="Add Medication"></td>
    		</tr>
    	</table>
    </body>
    </html>
    This code works in mozilla firefox but not internet explorer...
    Am I doing something wrong?

    Thanks,

    Nick

    ** EDIT ** Forgot to say what the script does...
    Whenever the user clicks add medication it creates a new input box to be appended inside of the cMeds table... That way the user can create as many input boxes as needed..
    Nicholas Rhodes
    Asgard Development
    http://www.asgard-dev.com

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,238
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    tables in IE

    I have seen threads dealing with differences in the way IE treats tables. IE adds a tbody tag after the table tag, and that can mess up DOM scripts sometimes. Also, if I'm not mistaken (which I very well could be) IE adds a text node inside td cells.

  3. #3
    SitePoint Addict y_oda2002's Avatar
    Join Date
    May 2005
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know of any ways around that?
    Nicholas Rhodes
    Asgard Development
    http://www.asgard-dev.com

  4. #4
    SitePoint Addict y_oda2002's Avatar
    Join Date
    May 2005
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually that was enough...

    I added a <tbody></tbody> tag to the table and appended everything to it...

    Internet Exploder works fine now..

    Thanks
    Nicholas Rhodes
    Asgard Development
    http://www.asgard-dev.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •