getting iframe information to be used by the form it is in?

Joined
12 Feb 2006
Posts
17,628
Location
Surrey
first would like to say when making a script for first time i will usually make it by myself without an other examples so i learn from my mistakes, different methods, and exactly how it works rather then just looking at something that works and using it, so the method may seem mad but it's just what i thought to do first.

so i have a "comments" form which the user have a load of fields such as email, name, comments, and images.

To upload images i decided to use iframes so that the user could upload each image without a page refresh needed or going to another page. This works all fine, however i now want to use information from within the iframe, such as image location, to store in a database along with the comment, email etc.

how would i do this?
 
So you got an iFrame with some elements in it, which you want to get the values of?
in Vbscript you would write Document.All.iFrame.ElementName.Value
Can remember the java script version at the moment, I really need to learn java script lol, stupid microsoft loving company I work for uses vbScript -.-
Edit: Also you may want to look at using an XMLHttpRequest object rather than an iFrame, its a more modern way of doing things.
 
Last edited:
thanks for the reply. will have a look at what you suggested.

i got it working by using javascript, basically as you have said, but i was hoping to do it without, as the result of the iframe is what is needed,
 
bugger what i have isn't working.

so i have a form with one of the text input fields named img1 wrapped in a div with the id of imgId1, this starts as the value of $img1 if there is anything else it is blank so user to input.

now when the user uploads an image in the iframe javascript will replace whats inside the div imgId1 with another input field exactly the same but the value is the name of the image which is from the iframe.

trouble i got now is that when i submit the form this new input field is not recognized so then the value is not posted.

anyone know why this might be? do forms not like new input fields being added?

viewing the generated source it is appearing as it should, with the new input field with new value, except oddly the type="text" is displayed at the end and not at the beginning like written in both codes :confused:

[edit]


got it working :) unsure fully why, but it was as suspected in that i couldn't replace the whole input field, instead i had to get the input field and set it's value, makes much more sense but i don't understand why there was a problem with replacing the whole thing as the code ended up the same any way.
 
Last edited:
Back
Top Bottom