stockton Posted June 1, 2007 Share Posted June 1, 2007 For some reason or other I have up until now believed that for Javascript(Ajax) to be able to update fields on a web page those fields had to be defined within <div> </div?> tags. I now suspect that this belief is wrong and as long as those fields have a unique id their cantent can be accessed and updated via getElementById. Quote Link to comment Share on other sites More sharing options...
brissy_matty Posted June 1, 2007 Share Posted June 1, 2007 i originally thought that however quickly found when first experimenting that you can update table fields or virtually anything with an ID tag Quote Link to comment Share on other sites More sharing options...
obsidian Posted June 1, 2007 Share Posted June 1, 2007 Take this a step further... by learning how to manipulate the DOM, you can apply AJAX actions to any element on the page. Divs are a good choice since they have no space in and of themselves, but referencing an element by hierarchy or name alone is possible. Any element that can be referenced through Javascript can be used as the recipient of an AJAX call. Quote Link to comment Share on other sites More sharing options...
stockton Posted June 1, 2007 Author Share Posted June 1, 2007 Thanks guys(& I am not being sexist.....:-) ) Quote Link to comment Share on other sites More sharing options...
mainewoods Posted June 5, 2007 Share Posted June 5, 2007 one issue with updating anything with an id tag. If you try to innerHTML a block level item into an inline item, trouble: <script> // don't do this document.getElementById('test').innerHTML = '<div>hello</div>'; </script> <span id="test"></span> --violation of well formed document Quote Link to comment Share on other sites More sharing options...
obsidian Posted June 5, 2007 Share Posted June 5, 2007 one issue with updating anything with an id tag. If you try to innerHTML a block level item into an inline item, trouble: <script> // don't do this document.getElementById('test').innerHTML = '<div>hello</div>'; </script> <span id="test"></span> --violation of well formed document Also, keep in mind that IE won't let you use innerHTML to write to certain elements (only read). Quote Link to comment Share on other sites More sharing options...
stockton Posted June 5, 2007 Author Share Posted June 5, 2007 Thanks. BTW How should one do it to enable IE? Quote Link to comment Share on other sites More sharing options...
r-it Posted June 5, 2007 Share Posted June 5, 2007 The way i'm doing it, I've been forced by stupid ie to ommit the form tag, so i'm using getelementbyid to get my stuff and then i use ajax to validate it with my php Quote Link to comment Share on other sites More sharing options...
stockton Posted June 5, 2007 Author Share Posted June 5, 2007 and if you want to output data to the HTML page? I am using document.getElementById("SlotsIssued").innerHTML = SlotsIssued; will this work with IE. I cannot test it as I am on a Linux box and unless one goes to the trouble of installing Wine etc etc IE does not work on Linux. Quote Link to comment Share on other sites More sharing options...
mainewoods Posted June 5, 2007 Share Posted June 5, 2007 Also, keep in mind that IE won't let you use innerHTML to write to certain elements (only read). obsidian, you mean like elements that just wouldn't make sense for innerHTML, like tr, input, or maybe ul? Probably li is allowed. I never tried any of those, I always just use div. Out of curiousity, what item can only be read by innerHTML but not written to? Quote Link to comment Share on other sites More sharing options...
obsidian Posted June 6, 2007 Share Posted June 6, 2007 Also, keep in mind that IE won't let you use innerHTML to write to certain elements (only read). obsidian, you mean like elements that just wouldn't make sense for innerHTML, like tr, input, or maybe ul? Probably li is allowed. I never tried any of those, I always just use div. Out of curiousity, what item can only be read by innerHTML but not written to? No, I mean that there are actually elements (specifically table elements other than <td>) that IE cannot write to using innerHTML (IE 6 at least). I don't typically link to Microsoft for references, but this one is actually addressed in their own support forums: http://support.microsoft.com/kb/239832 CAUSE The innerHTML property of the TABLE, TFOOT, THEAD, and TR elements are read-only. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.