PDA

View Full Version : Dynamic Ajax Content: Innerhtml and form issue



scraf
12-05-2006, 03:51 PM
[SOLVED]

1) Script Title:
Dynamic Ajax Content
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
3) Describe problem:

This script worked like a charm ( thank you to the author('s) ), however I managed to break it. :(

I have an input form for "new" users, I have a dropdown list that throws existing user details into a <div> using the script.

However, when I take that dropdown goes back to the default, that is the input form, out favourite browser IE throws a JavaScript error...



Error: Object doesn't support this property or method


Thanks to this chap (http://integralpath.blogs.com/thinkingoutloud/2006/03/innerhtml_and_n.html#comments), I have narrowed it down to "The short answer is that form is a non-block element and you cannot insert a block element inside a non-block element".

However I have no idea how to fix this in my case.

The line that throws the error is ( line 42 from the "function loadpage").



document.getElementById(containerid).innerHTML=page_request.responseText


TIA

jscheuer1
12-05-2006, 04:54 PM
Where is the form to begin with? Is it on the 'top' page or on an external page? If it is on the 'top' page, I don't believe this script is written to accommodate that, unless the form is also on an external page. On the external page, if the HTML isn't valid, that will present problems. You can validate your external page (by itself) here:

http://validator.w3.org/

scraf
12-05-2006, 05:21 PM
Validation hasn't been on my list of priorities as this is only for an admin section for a site, and at first look will probably take a lot of debugging. :(

The form is originally in the <div> that the script talks to

The form in that div gets replaced by other external data ( other pages ) through choices from the select dropdown.

However when that external data contains a form ( I actually want it to be the same one that originally shows ), then IE throws the error.

scraf
12-05-2006, 05:25 PM
Hmm, a workaround could be if I could some how get the css to have a "display:none" for the form when weaving the Ajax magic.

Which would probably involve using an iframe instead I guess. :(

jscheuer1
12-05-2006, 05:30 PM
I'm pretty good at getting pages to validate. If your external page containing the form isn't too complex, I'd be happy to validate it for you. Please supply a link to it (preferred) or the full and exact code*. There could be other problems but, in the past this (invalid markup) has proven to be the problem in cases like this so, you have to at least start with valid markup.



*Please provide your code -

PLEASE: Include the URL to your problematic webpage that you want help with. (Best)

OR:

Put code tags:




code goes here



around your code (as explained here (http://www.dynamicdrive.com/forums/misc.php?do=bbcode#code)) in a message here so that it appears like so:




code goes here

scraf
12-05-2006, 06:02 PM
You're probably right about the validation John, I ran a test and no problems...

http://scraf.nl/ajax/test.php

I'll pm you the actual page with the problem ( IE only issue ), and walk away for an hour ( spent far too long behind the screen ).

Validation is not important for the actual page, and I, er got, 60 errors.

scraf
12-05-2006, 08:27 PM
[SOLVED]

( Wish I could add that to the title of the thread )

jscheuer1 hit the nail right on the head with the validation prognosis.

Speaking of heads, I had forgotten to close the <head> tag in the code. :o

Problem solved.

scraf
12-05-2006, 08:35 PM
Footnote: '<select id="ajaxmenu" onChange=' .....didn't validate

'<select id="ajaxmenu" onchange=' .... did