Community Supporter?
What a dork
Posts: 17
114 credits Members referred : 0
« on: Oct 03, 2007, 05:58:07 AM »
This will cover attachments from the ground up and will move into fancy AJAX Jscript objects.
We start with a simple web page (index.html) that has an iframe in it which has a form. The page will have a link when clicked will submit the form that is the iframe page.
« Last Edit: Oct 04, 2007, 06:40:03 AM by apple2 »
Community Supporter?
What a dork
Posts: 17
114 credits Members referred : 0
« Reply #1 on: Oct 03, 2007, 06:00:27 AM »
Most easy way to attach without refresh is to use IFRAMES.
Structure of example:
File 1: web page code with link iframe code includes file 2 inside of file 1 jscript to activate the form in file 2
File 2: form
File 3: page returned when form is submitted this page has the ablity to update information in file 1 such as show the image that was attached.
AGAIN: File 1 includes File 2 in it. You don't load File 2 directly. File 2 is loaded with an iframe tag.
To submit file 2 the link in file 1 activates Javascript which has access through jscript commands to the form in File 2. The submit function is called by Javascript as if you had clicked it in the second form.
« Last Edit: Oct 04, 2007, 06:39:34 AM by apple2 »
Community Supporter?
What a dork
Posts: 17
114 credits Members referred : 0
<HTML> <BODY> <Form name='iframeform' method=post action='test.html'> This is a form in the file iframe.html<br> Click the submit link below which is in index.html to submit me!<br> Text field: <input type=text name='temp'><br> Images: <input type=file name='file'> </Form> </BODY> </HTML>
test.html
<HTML> <BODY> Without refreshing the whole page I appear!<br> The browser is showing index.html<br> This is the output from test.html which was called by iframe.html<br> Iframe.html is included in index.html by usign the iframe tag.<br> </BODY> </HTML>
What is going on: In index.html which is the page you pull up in the browser you include another web age in a box called iframe.html
In index.html we have a link when clicked it submits the form in the iframe. To do that jscript needs to know the name of the iframe and the name of the form in the iframe.
get the document model object for the frame: frames['theiframe'].document. get the form object in that page named iframeform and call its submit function: .forms['iframeform'].submit()
« Last Edit: Oct 04, 2007, 06:51:29 AM by apple2 »
Community Supporter?
What a dork
Posts: 17
114 credits Members referred : 0
Roadmap
« Reply #3 on: Oct 04, 2007, 06:31:43 AM »
Whats next? We will add some PHP to take the uploaded image. When you click browse jscript can automatically submit the form. The resulting page that comes back will be the same form so we can add another attachment. Each time an attachment is added it will update the main page with an image of the attachment.
Bell and whistle: Sometimes it is nice to add attachments in the post text. A new BBcode is to include attachments inline with [attachment=] and below your post is a link by each attachment which adds it.
« Last Edit: Oct 04, 2007, 06:51:58 AM by apple2 »
Community Supporter?
What a dork
Posts: 17
114 credits Members referred : 0
« Reply #4 on: Oct 10, 2007, 06:29:30 AM »
Alright now I've got it uploading attachments. Ideally it would handle gifs off to PHP. I probably won't post more here unless you ask a question. Thanks!
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7181