Microsoft Windows Vista Community Forums - Vistaheads
Recommended Download



Welcome to the Microsoft Windows Vista Community Forums - Vistaheads, YOUR Largest Resource for Windows Vista related information.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so , join our community today!

If you have any problems with the registration process or your account login, please contact us.

Driver Scanner

client-side scripting, html dom weirdness -help?

microsoft.public.internetexplorer.general






Speedup My PC
Reply
  #1 (permalink)  
Old 02-18-2010
Mark
 

Posts: n/a
client-side scripting, html dom weirdness -help?
I don't know if this is the right group for this... All the groups that have
scripting explicitly in the title seem deader than a doornail.

I've got a scripting problem that's driving me nuts... First let me say I
know most of what follows is really bad practice but the code used to work
(still does on some websites) but suddenly stopped working on our new site
and I haven't been able to figure out what the difference is.

We've got a form that gathers user input. Within that form, client-side
script injects another little form that uploads a file in a sort of ajax-y
way; if there's an upload, the client-side scripts takes the json result and
sets other values in the form with it.

The *really* bad practice is that the injected form has some inputs with the
same names as inputs in the outer form. I'm still puzzling through why it
ever worked.

To boil it *way* down to demonstrate, we have something like
<body onload="injectform(document.getElementById('inject Here'))">
<form method="post" action="foo.aspx" id="mainForm">
<input type="hidden" name="foo" value="">
<input type="submit" onclick="document.mainForm.foo='done';return false;">
....
<div id="injectHere"></div>
<script language="javascript">
function injectForm(parentEl)
{
var frm=document.createElement("form");
parentEl.appendChild(frm);
frm.method="post";
frm.enctype="multipart/form-data";
frm.encoding="multipart/form-data";
frm.action="bar.aspx";
var fileCtl=document.createElement("input");
fileCtl.type="file";
fileCtl.name="fileCtl";
fileCtl.onchange=function(evt){fileChosenCallback( fileCtl);};
frm.appendChild(fileCtl);
frm.style.margin="0";
var
ctl=document.createElement("input");ctl.type="hidd en";ctl.name="foo";frm.appendChild(ctl);ctl.value= "bar";
}
</script>
....
</form>
</body>

So in scripting, document.forms.length = 2 and document.forms[1] is nested
in document.forms[0]. The problem we've just started seeing is when the
submit button is clicked, the "foo" input is not being updated by the onClick
code.

Here's the difference I've been able to see in the debugger:
In the old sites where it works the debugger shows,
1) document.forms[1].foo is undefined
2) document.forms[1].outerHTML has all the injected inputs but all the name=
have been snipped out - there are no displayed name attributes at all.
3) document.forms[0].foo resolves to a single input element - the first
declared one.

In the new site where it's broken, the debugger shows,
1) document.forms[1].foo resolves to the injected foo input
2) document.forms[1].outerHTML shows all the name= attributes
and
3) document.forms[0].foo resolves to an element collection. The onClick
code sets .value on the collection (which apparently goes quietly into the
ether without making a ripple).

So under what circumstances does the HTML dom hide the names on nested form
inputs? That seems to be the only reason why the crap ever did anything at
all. I've compared the script that's injecting the form and that's all the
same. I've compared the html being generated immediately around the parent
forms and that's all the same.

But for some reason perhaps in an outer circle of hell, the javascript dom
simply choses not to see the names of inputs in nested forms. Now suddenly
it is and I haven't been able to nail down why...

Any clues would be appreciated...

Thx
Mark

Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-19-2010
rob^_^
 

Posts: n/a
Re: client-side scripting, html dom weirdness -help?
Hi,

No nested forms. Its invalid markup.

"Mark" <mmodrall@nospam.nospam> wrote in message
news:EC5AB147-D4C9-4E35-8E9A-EF52BF07AE26@microsoft.com...
> I don't know if this is the right group for this... All the groups that
> have
> scripting explicitly in the title seem deader than a doornail.
>
> I've got a scripting problem that's driving me nuts... First let me say I
> know most of what follows is really bad practice but the code used to work
> (still does on some websites) but suddenly stopped working on our new site
> and I haven't been able to figure out what the difference is.
>
> We've got a form that gathers user input. Within that form, client-side
> script injects another little form that uploads a file in a sort of ajax-y
> way; if there's an upload, the client-side scripts takes the json result
> and
> sets other values in the form with it.
>
> The *really* bad practice is that the injected form has some inputs with
> the
> same names as inputs in the outer form. I'm still puzzling through why it
> ever worked.
>
> To boil it *way* down to demonstrate, we have something like
> <body onload="injectform(document.getElementById('inject Here'))">
> <form method="post" action="foo.aspx" id="mainForm">
> <input type="hidden" name="foo" value="">
> <input type="submit" onclick="document.mainForm.foo='done';return false;">
> ...
> <div id="injectHere"></div>
> <script language="javascript">
> function injectForm(parentEl)
> {
> var frm=document.createElement("form");
> parentEl.appendChild(frm);
> frm.method="post";
> frm.enctype="multipart/form-data";
> frm.encoding="multipart/form-data";
> frm.action="bar.aspx";
> var fileCtl=document.createElement("input");
> fileCtl.type="file";
> fileCtl.name="fileCtl";
> fileCtl.onchange=function(evt){fileChosenCallback( fileCtl);};
> frm.appendChild(fileCtl);
> frm.style.margin="0";
> var
> ctl=document.createElement("input");ctl.type="hidd en";ctl.name="foo";frm.appendChild(ctl);ctl.value= "bar";
> }
> </script>
> ...
> </form>
> </body>
>
> So in scripting, document.forms.length = 2 and document.forms[1] is nested
> in document.forms[0]. The problem we've just started seeing is when the
> submit button is clicked, the "foo" input is not being updated by the
> onClick
> code.
>
> Here's the difference I've been able to see in the debugger:
> In the old sites where it works the debugger shows,
> 1) document.forms[1].foo is undefined
> 2) document.forms[1].outerHTML has all the injected inputs but all the
> name=
> have been snipped out - there are no displayed name attributes at all.
> 3) document.forms[0].foo resolves to a single input element - the first
> declared one.
>
> In the new site where it's broken, the debugger shows,
> 1) document.forms[1].foo resolves to the injected foo input
> 2) document.forms[1].outerHTML shows all the name= attributes
> and
> 3) document.forms[0].foo resolves to an element collection. The onClick
> code sets .value on the collection (which apparently goes quietly into the
> ether without making a ripple).
>
> So under what circumstances does the HTML dom hide the names on nested
> form
> inputs? That seems to be the only reason why the crap ever did anything
> at
> all. I've compared the script that's injecting the form and that's all
> the
> same. I've compared the html being generated immediately around the
> parent
> forms and that's all the same.
>
> But for some reason perhaps in an outer circle of hell, the javascript dom
> simply choses not to see the names of inputs in nested forms. Now
> suddenly
> it is and I haven't been able to nail down why...
>
> Any clues would be appreciated...
>
> Thx
> Mark
>
>

Reply With Quote
  #3 (permalink)  
Old 02-19-2010
PA Bear [MS MVP]
 

Posts: n/a
Re: client-side scripting, html dom weirdness -help?
Developer-specific resources include:

MSDN IE Development Forum (post such questions here instead)
http://social.msdn.microsoft.com/For...opment/threads

IE Developer Center
http://msdn.microsoft.com/en-us/ie/default.aspx

Learn IE8
http://msdn.microsoft.com/en-us/ie/aa740473.aspx

HTML and DHTML Overviews and Tutorials
http://msdn.microsoft.com/en-us/library/ms537623.aspx and

Cascading Style Sheets (CSS)
http://msdn2.microsoft.com/en-us/ie/aa740476.aspx

Expression Web SuperPreview for Internet Explorer (free, stand-alone visual
debugging tool for IE6, IE7, and IE8)
http://www.microsoft.com/downloads/d...b-dccff3fae677

Expression Web SuperPreview Release Notes
http://www.microsoft.com/expression/...easeNotes.aspx

Validators:
http://validator.w3.org/
http://jigsaw.w3.org/css-validator/


Mark wrote:
> I don't know if this is the right group for this... All the groups that
> have scripting explicitly in the title seem deader than a doornail.
>
> I've got a scripting problem that's driving me nuts... First let me say I
> know most of what follows is really bad practice but the code used to work
> (still does on some websites) but suddenly stopped working on our new site
> and I haven't been able to figure out what the difference is.
>
> We've got a form that gathers user input. Within that form, client-side
> script injects another little form that uploads a file in a sort of ajax-y
> way; if there's an upload, the client-side scripts takes the json result
> and
> sets other values in the form with it.
>
> The *really* bad practice is that the injected form has some inputs with
> the
> same names as inputs in the outer form. I'm still puzzling through why it
> ever worked.
>
> To boil it *way* down to demonstrate, we have something like
> <body onload="injectform(document.getElementById('inject Here'))">
> <form method="post" action="foo.aspx" id="mainForm">
> <input type="hidden" name="foo" value="">
> <input type="submit" onclick="document.mainForm.foo='done';return false;">
> ...
> <div id="injectHere"></div>
> <script language="javascript">
> function injectForm(parentEl)
> {
> var frm=document.createElement("form");
> parentEl.appendChild(frm);
> frm.method="post";
> frm.enctype="multipart/form-data";
> frm.encoding="multipart/form-data";
> frm.action="bar.aspx";
> var fileCtl=document.createElement("input");
> fileCtl.type="file";
> fileCtl.name="fileCtl";
> fileCtl.onchange=function(evt){fileChosenCallback( fileCtl);};
> frm.appendChild(fileCtl);
> frm.style.margin="0";
> var
> ctl=document.createElement("input");ctl.type="hidd en";ctl.name="foo";frm.appendChild(ctl);ctl.value= "bar";
> }
> </script>
> ...
> </form>
> </body>
>
> So in scripting, document.forms.length = 2 and document.forms[1] is nested
> in document.forms[0]. The problem we've just started seeing is when the
> submit button is clicked, the "foo" input is not being updated by the
> onClick code.
>
> Here's the difference I've been able to see in the debugger:
> In the old sites where it works the debugger shows,
> 1) document.forms[1].foo is undefined
> 2) document.forms[1].outerHTML has all the injected inputs but all the
> name=
> have been snipped out - there are no displayed name attributes at all.
> 3) document.forms[0].foo resolves to a single input element - the first
> declared one.
>
> In the new site where it's broken, the debugger shows,
> 1) document.forms[1].foo resolves to the injected foo input
> 2) document.forms[1].outerHTML shows all the name= attributes
> and
> 3) document.forms[0].foo resolves to an element collection. The onClick
> code sets .value on the collection (which apparently goes quietly into the
> ether without making a ripple).
>
> So under what circumstances does the HTML dom hide the names on nested
> form
> inputs? That seems to be the only reason why the crap ever did anything
> at
> all. I've compared the script that's injecting the form and that's all
> the
> same. I've compared the html being generated immediately around the
> parent
> forms and that's all the same.
>
> But for some reason perhaps in an outer circle of hell, the javascript dom
> simply choses not to see the names of inputs in nested forms. Now
> suddenly
> it is and I haven't been able to nail down why...
>
> Any clues would be appreciated...
>
> Thx
> Mark


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I clear the Client Side Cache (CSC) R Mears microsoft.public.windows.vista.general 8 09-14-2011 12:58
Enabling Client side target Olu microsoft.public.windowsupdate 1 02-18-2010 18:54
Anyone bothering with client-side AV anymore? Steve Security News 0 09-03-2008 15:50
PayPal plugs cross-site scripting hole that side-stepped stronger security Steve Security News 0 05-19-2008 19:10
Article ID: 938092 You may be unable to delete the cache of offline files from the client-side caching (CSC) cache on an offline Windows Vista-based client computer KBArticles English 0 10-22-2007 20:00




All times are GMT +1. The time now is 06:56.




Driver Scanner - Free Scan Now

Vistaheads.com is part of the Heads Network. See also XPHeads.com , Win7Heads.com and Win8Heads.com.


Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.0 RC 2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120