|
|||
|
Hi everybody!
I am experiencing a strange - at least for me - phenomen. I have a func containing the following code : alert (document.forms['photoUpload'].elements['photo_1'].value); // document.forms['photoUpload'].submit(); document.photoUpload.submit(); This code works perfectly in the FF, but not in the IE. The alert outputs the proper value of the element photo_1 and then the line with submit() produces [objectError] - checked by means of try-catch and displayed with alert(e) in the catch-block. This concerns the both lines with the submit(). What could be a cause for this problem? Victor |
|
|
||||
|
||||
|
|
|
|||
|
Victor wrote:
> // document.forms['photoUpload'].submit(); > document.photoUpload.submit(); The first form is preferred. Why is it commented out? > This code works perfectly in the FF, but not in the IE. The alert > outputs the proper value of the element photo_1 and then the line with > submit() produces [objectError] First thing I would check is to make sure you don't have an input named "submit". -- Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com |
|
|||
|
Matt Kruse schrieb: > Victor wrote: > > // document.forms['photoUpload'].submit(); > > document.photoUpload.submit(); > > The first form is preferred. Why is it commented out? > Neither of the both wants to work here. The outcommented line has been simply copied from the running code, never mind about it. > > This code works perfectly in the FF, but not in the IE. The alert > > outputs the proper value of the element photo_1 and then the line with > > submit() produces [objectError] > > First thing I would check is to make sure you don't have an input named > "submit". > No, I don't ! However, I have discovered that the problem gets eliminated when I try to upload a different form rather than the 'photoUpload', which has (!!!!) encode='multipart/form-data'. Can this be the real source of the problem? If yes, then how to fix it? And why does it work in the FF? Regards Victor |
|
|||
|
"Victor" <big.boss@chefmail.de> wrote in message news:1166733276.670791.276890@f1g2000cwa.googlegro ups.com... > Hi everybody! > > I am experiencing a strange - at least for me - phenomen. > I have a func containing the following code : > > alert (document.forms['photoUpload'].elements['photo_1'].value); > > // document.forms['photoUpload'].submit(); > document.photoUpload.submit(); > > This code works perfectly in the FF, but not in the IE. The alert > outputs the proper value of the element photo_1 and then the line with > submit() produces [objectError] - checked by means of try-catch and > displayed with alert(e) in the catch-block. This concerns the both > lines with the submit(). > > What could be a cause for this problem? > > Victor Why do you have "document.forms['photoUpload'].elements['photo_1'].value" in the alert but "document.photoUpload" when you call the submit function? perhaps if you had "document.photoUpload" in the alert too or document.forms['photoUpload'].elements['photo_1'].submit, you may get a different result. HTH > |
|
|||
|
Victor wrote:
> However, I have discovered that the problem gets eliminated when I try > to upload a different form rather than the 'photoUpload', which has > (!!!!) encode='multipart/form-data'. Can this be the real source of > the problem? I don't know. I would take these steps: 1. Try submitting the form manually, without javascript 2. Try taking elements out of the form until it works, then figure out which piece made it break 3. Have a non-script fall-back, so even in the event of errors like this, the form would still get submitted -- Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com |
|
|||
|
> Why do you have "document.forms['photoUpload'].elements['photo_1'].value" in
> the alert but "document.photoUpload" when you call the submit function? if you > had perhaps "document.photoUpload" in the alert too or > document.forms['photoUpload'].elements['photo_1'].submit, you may get a > different result. > I did try it with the 'document.forms['photoUpload']... ' in the alert and with the 'document.photoUpload.submit()' without any different result... Victor |
|
|||
|
Victor wrote:
> I am experiencing a strange - at least for me - phenomen. > I have a func containing the following code : > > alert (document.forms['photoUpload'].elements['photo_1'].value); > > // document.forms['photoUpload'].submit(); > document.photoUpload.submit(); > > This code works perfectly in the FF, but not in the IE. The alert > outputs the proper value of the element photo_1 and then the line with > submit() produces [objectError] - checked by means of try-catch and > displayed with alert(e) in the catch-block. This concerns the both > lines with the submit(). > > What could be a cause for this problem? I might have reconstructed your problem: <script type="text/javascript"> function sV() { alert (document.forms['photoUpload'].elements['photo_1'].value) document.photoUpload.submit() } </script> <form method="post" action="script.php" id="photoUpload"> <input type="file" name="photo_1"> <input type="button" value="click me" onClick="sV();"> </form> IE says "document.photoUpload is empty or no object". FF says "document.photoUpload has no properties". There are a number of things that are not good in this kind of code. Better: <form method="post" action="script.php" name="photoUpload" enctype="multipart/form-data" onSubmit=" alert(document.forms['photoUpload'].elements['photo_1'].value)"> <input type="file" name="photo_1"> <input type="submit" value="click me"> </form> Is the alert only meant for debugging purposes ? Then the onSubmit-handler can be left out. -- Bart |
|
|||
|
Victor wrote:
> [...] > However, I have discovered that the problem gets eliminated when I try > to upload a different form rather than the 'photoUpload', which has > (!!!!) encode='multipart/form-data'. Can this be the real source of the > problem? If yes, then how to fix it? And why does it work in the FF? The right syntax is enctype="multipart/form-data" and not encode='multipart/form-data' AFAIK, this should normally not affect the javascript. But it's necessary to add it for other reasons (to be technical, so that your parsing program - e.g. PHP, ASP... - knows that the POST-request consists of multiple parts divided by a defined separator). -- Bart |
|
|||
|
Malkavian wrote:
> "Victor" <big.boss@chefmail.de> wrote in message > >> alert (document.forms['photoUpload'].elements['photo_1'].value); >> // document.forms['photoUpload'].submit(); >> document.photoUpload.submit(); > > Why do you have "document.forms['photoUpload'].elements['photo_1'].value" in > the alert but "document.photoUpload" when you call the submit function? > perhaps if you had "document.photoUpload" in the alert too or > document.forms.['photoUpload'].elements['photo_1'].submit, you may get a > different result. You can't do document.forms['photoUpload'].elements['photo_1'].submit() Perhaps you meant document.forms['photoUpload'].submit() The latter is a difference compared to document.photoUpload.submit() if one uses id="photoUpload" inside the <form>-tag. In my experience I prefer name="photoUpload" . Maybe that's just a habit. -- Bart |
|
|||
|
"Victor" <big.boss@chefmail.de> wrote in message news:1167081938.679715.90860@79g2000cws.googlegrou ps.com... >> Why do you have "document.forms['photoUpload'].elements['photo_1'].value" >> in >> the alert but "document.photoUpload" when you call the submit function? >> if you >> had perhaps "document.photoUpload" in the alert too or >> document.forms['photoUpload'].elements['photo_1'].submit, you may get a >> different result. >> > I did try it with the 'document.forms['photoUpload']... ' in the alert > and with the 'document.photoUpload.submit()' without any different > result... > > Victor > I wasn't being picky. It's just that mixing name conventions causes a lot of headaches. |
|
|||
|
"Bart Van der Donck" <bart@nijlen.com> wrote in message news:1167135705.767765.260820@48g2000cwx.googlegro ups.com... > Malkavian wrote: > >> "Victor" <big.boss@chefmail.de> wrote in message >> >>> alert (document.forms['photoUpload'].elements['photo_1'].value); >>> // document.forms['photoUpload'].submit(); >>> document.photoUpload.submit(); >> >> Why do you have "document.forms['photoUpload'].elements['photo_1'].value" >> in >> the alert but "document.photoUpload" when you call the submit function? >> perhaps if you had "document.photoUpload" in the alert too or >> document.forms.['photoUpload'].elements['photo_1'].submit, you may get a >> different result. > > You can't do > > document.forms['photoUpload'].elements['photo_1'].submit() > > Perhaps you meant > > document.forms['photoUpload'].submit() Yes, I did. My bad. Thanks for pointing that out. > > The latter is a difference compared to document.photoUpload.submit() > if one uses id="photoUpload" inside the <form>-tag. In my experience > I prefer name="photoUpload" . Maybe that's just a habit. I do too but min is from old habit. I don't think that older mozilla/netscape browsers recognise the ID tag but i could be wrong.. > > -- > Bart > |
|
|||
|
Victor wrote:
> Somehow until now nobody has commented the fact that my code works > perfectly in the FireFox. The problem occurs only in the MSIE 6 (I did > not test it with other IE versions). You still haven't posted your actual code, including HTML. How are we supposed to help you? Either: a) Post a url that demonstrates the problem or b) Take your generated HTML, remove everything that is not necessary to show the problem, and post the result here I'm fairly certain your problem will be resolved very quickly. -- Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com |
|
|||
|
Victor wrote on 26 dec 2006 in comp.lang.javascript:
> Somehow until now nobody has commented the fact that my code works > perfectly in the FireFox. The problem occurs only in the MSIE 6 (I did > not test it with other IE versions). > > Any ideas to this point ? > Sure, if you do not quote, how should we know what you are talking about? On usenet you cannot expect the last posting still or already to be on each news server. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress) |
|
|||
|
Victor wrote: > Somehow until now nobody has commented the fact that my code works > perfectly in the FireFox. That's possibly because no one has seen your code so far. There were two lines posted and corrected by respondents. if you have a form with NAME "photoUpload" (ID is not relevant) and it has element with NAME "photo_1" (ID is not relevant) then document.forms['photoUpload'].elements['photo_1'].value will give you photo_1 value (or allowed part of value if type="file") document.forms['photoUpload'].submit() will submit this form (unless you managed to create a control in your form named "submit") That works for all ever existed browsers since Netscape 2.0 If anything fails to work then you have much more serious problems then two lines of code. Without seeing the whole page by URL any further guessing is rather futile. |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: Command line macro to submit SAS code | Jim Groeneveld | Newsgroup comp.soft-sys.sas | 0 | 04-19-2006 08:31 AM |
| Re: Command line macro to submit SAS code | toby dunn | Newsgroup comp.soft-sys.sas | 0 | 04-19-2006 02:22 AM |
| Re: weblog to normal form | Sigurd Hermansen | Newsgroup comp.soft-sys.sas | 0 | 04-12-2006 09:13 PM |
| Re: SQL, reduced normal form and dummy variables | Sigurd Hermansen | Newsgroup comp.soft-sys.sas | 0 | 05-09-2005 10:07 PM |
| How to create a survey form using SAS ODS - PDF or RTF | Kassa2 Bellew | Newsgroup comp.soft-sys.sas | 0 | 12-08-2004 11:36 AM |