|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
Anyone ????
|
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
Joe,
Quote:
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. |
|
#7
|
|||
|
|||
|
Quote:
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 |
|
#8
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > Webmail - javascript:document.forms[0].submit() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|