Hi, I new to the whole javascript and webdesign game. So here is my question:
From the parent window I want to open a child window and then from the same function to change a value on a form in the child window. Here is what I have for code:
I use to have a simpler function that tried to open window and directly change the values, but then once it was finished loading it would change everything back to its original value.
Any ideas what does this and how to solve this problem which has had me pulling at my hair the whole day?
Instead of using script to set values in form controls during HTML parsing of the child window or even after it is loaded (parsed), why not use script to write the HTML markup as script strings, allowing you to set the form control values directly?
Does that mean that I have to write the php code, styling and other html code through the script as well, or is there a way where I can simply write between the <body></body> tag ??
So if I'm getting you right, I should write the whole form through script?
When creating a child window through script, the HTML and everything else basically written in using document.write() methods for HTML (you have to use DOM methods for XHTML, since document.write() is undefined). Doesn't have to be literal strings. Any text you can take in from inline or external JS files, or even references to displayed/visible or undisplayed/invisible content of DOM nodes.
Originally Posted by ZenAnthro
Does that mean that I have to write the php code, styling and other html code through the script as well, or is there a way where I can simply write between the <body></body> tag ??
Your first document is an (X)HTML that contains a button or I suppose an anchor as you have it, that opens the child window with the form to be completed, and perhaps some controls (text boxes) filled with default or dynamically added values. You have the form submit to send the form data to the server and call the PHP document.
Your PHP document (second document) must extract data from the form and then you must set up strings that compose the email message if the PHP mail() function is to perform properly. You would extract the form data using name references to the POST associative array, then you just
The simple PHP tutorial shows you how to print form data, but instead of printing, just set up strings for your email message, and then pass those parameters to the mail() function.
Your PHP document should also contain a note sent to the form submitter as to whether the form data was emailed successfully or it failed. The mail() function should return a value indicating failure or success, and you use that value to have PHP echo text in the HTML document to be sent, with short body saying "Email successfully sent" or "Email could not be sent (for unknown reasons)".
Last edited by mavigozler; 08-25-2009 at 10:12 AM.
Reason: additional necessary comment
Eventually I went about passing the variable through the link and getting it with the php $_GET. But as you said,I formated my string through the php code and then sent it through the mail() function. As you said, I made sure that the email was sent successfully and if it was then it would send an alert() and close the form then.
Bookmarks