JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 26th, 2002, 02:36 AM
gstark gstark is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Sydney, Australia
Posts: 5 gstark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Webmail - javascript:document.forms[0].submit()

G'day y'all.

I'm new to PHP and I'm working through the article on Building a PHP-Based Mail Client.

Great article, but when I run the compose message script and press the "send" icon I get an error saying that there's no recipient entered when in fact I have entered that information.

In looking at the code I note that it's not using a form with a Submit button and then testing for a $Submit variable to see whether the data needs to be parsed and processed.

Instead, it's going to whatever is referenced by the anchor point defined with the send icon, that being "javascript:document.forms[0].submit() "

The problem seems to me as if the $to variable in the script isn't being passed to the send script from the compose script, but this seems to me from this code snippet that this function is being handled by the javascript code mentioned above.

I can't see any references in the article to the javascript, and I've not seen this sort of language usage before. I cannot see any references to this sort of usage in the PHP docs either.

I would greatly appreciate it if someone could explain to me this usage, and how it works, and also where I could find some documentation on this.

Thanx in advance for any and all help.

Reply With Quote
  #2  
Old August 26th, 2002, 07:30 AM
SilkySmooth's Avatar
SilkySmooth SilkySmooth is offline
Newbie :P
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2001
Location: In the PHP Engine :-)
Posts: 2,880 SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 32 m 23 sec
Reputation Power: 15
Hi,

Could you post the link to this article, it's often easier to look at the code to identify and explain something than based on an explanation, well thats what I find anyway
__________________
---------------------
-- SilkySmooth --
---------------------
Proxy | Little Directory

Reply With Quote
  #3  
Old August 26th, 2002, 09:07 AM
gstark gstark is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Sydney, Australia
Posts: 5 gstark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
No worries.

The article is at http://www.devshed.com/Server_Side/...ail1/page1.html

You'll need to download the source code for the article, as there's no mention of the javascript (that I can find) within the article itself. One of the javascript references occurs on line 39 of compose.php.

Reply With Quote
  #4  
Old August 27th, 2002, 05:38 PM
gstark gstark is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Sydney, Australia
Posts: 5 gstark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Anyone ????

Reply With Quote
  #5  
Old August 27th, 2002, 06:23 PM
4Life 4Life is offline
Please call me Joe ;)
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: the web
Posts: 244 4Life User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Hi,

document.forms[0].submit() refers to an array of forms (as in if you have more than one form). Try this: document.myform.submit() and <FORM NAME="myform"> (where 'my form' is the name of your form).

Cheers,
Joe of 4Life
__________________
Cheers,
Joe of 4Life

Check out 4Life today!

Reply With Quote
  #6  
Old August 27th, 2002, 07:44 PM
gstark gstark is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Sydney, Australia
Posts: 5 gstark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Joe,

Quote:
Originally posted by 4Life
Hi,

document.forms[0].submit() refers to an array of forms (as in if you have more than one form). Try this: document.myform.submit() and <FORM NAME="myform"> (where 'my form' is the name of your form).

Cheers,
Joe of 4Life



Many thanx for this.

So, to be sure I understand this, PHP builds an internal array of forms (defined with the <form> tag) and then this array gets referred to by it's zero based index offset into the array?

I presume that the index order would be the sequence within the form within which the individual form definitions are declared.

Of course, that didn't answer the other part of my question, which was why the contents of the variables ($to, $from, etc) were not being passed to the recipient form.

Anybody got any clues on that aspect?

tia.

Reply With Quote
  #7  
Old August 27th, 2002, 08:56 PM
Cira9999 Cira9999 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: San Francisco, CA
Posts: 226 Cira9999 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 13 sec
Reputation Power: 7
Quote:
So, to be sure I understand this, PHP builds an internal array of forms (defined with the <form> tag) and then this array gets referred to by it's zero based index offset into the array?


Well, it's not PHP that handles this, but JavaScript, although they work very well together. This is part of the DOM (Document Object Model) which works very much like a on big object, hence the meaning of DOM. At the top of the object is the window object followed by the document object, which represent the content of the window. Inside the document we have forms, and images, and buttons, and links, and so on. So you can control various aspects of the browser window through the DOM, so like 4Life said, document.forms[0].submit() refers to an array of forms, particulary, the first form, and then the submit button of that form.

Sorry to go off on a rant, but IMHO JavaScript is quite fun.

I'm looking at the source code right now, and the first thing I noticed is that the send.php page is not using $_POST["to"], but rather just the var $to. Using $_POST array instead of just the plain var is something that PHP has implemented in the newer versions OR if register globals if turned off in php.ini you must use the $_POST array.

However, are you able to get any data from the compose.php script? If you are, that's not it, and I shall keep looking.
__________________
-Samantha

Reply With Quote
  #8  
Old August 27th, 2002, 11:54 PM
gstark gstark is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Sydney, Australia
Posts: 5 gstark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Samantha,

Thanx very much for the detailed reply.

>> Well, it's not PHP that handles this, but JavaScript, although
>> they work very well together. This is part of the DOM
>> (Document Object Model) which works very much like a on
>> big object


More good stuff for me to research.

>> the first thing I noticed is that the send.php page is not
>> using $_POST["to"], but rather just the var $to. Using
>> $_POST array instead of just the plain var is something
>> that PHP has implemented in the newer versions OR if
>> register globals if turned off in php.ini you must use the
>> $_POST array.

OK. This sounds very much like it may be the source of my problem.

>> However, are you able to get any data from the
>> compose.php script?

No, not directly, and hence the reason for my query. I couldn't see how the data was being passed on to the next script.

It wasn't set up as a set of session variables, it wasn't being passed directly to the send.php script in the action directive, and I was getting an error in send saying that there was no valid "to" address.

For now I've worked around this by adding the variables to the action directive, but I'd like to understand the code as it was originally written.

I suspect that you've pointed me in the right direction, and for that I thank you.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Webmail - javascript:document.forms[0].submit()


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT