Link to home
Start Free TrialLog in
Avatar of girionis
girionisFlag for Greece

asked on

Submit a form within an iframe along with the main form.

Hello I have a main form which contains an iframe. The iframe itself also contains a from. I am trying to submit the iframe form alongside with the parent form. I am just wondering if this is possible without copying the iframe's form values into hidden fields in the main form.

Any thoughts on this are appreciated.

Thank you.
Avatar of girionis
girionis
Flag of Greece image

ASKER

Just to add, the iframe's form will eventually contain some inputs of type "file".
ASKER CERTIFIED SOLUTION
Avatar of dorward
dorward

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello dorward thank you for your quick reply. Yes I know about the value of the file inputs, that';s why I asked if I can do it without javascript.

I will look into using a <div> element and I will get back to you.
Ok using a div made things better but there is still a problem. I add the <input type="file"> dynamically to the form (we do not know in advance how many files the user will upload) but everytime I add a new file type it resets all the previous ones. I am using the following javascript:

divData.innerHTML = divData + "<input type='file'" + cnt + "'><br>"

where divData is the name of the div element and cnt is a global counter.

If I try to do it differently, adding an element to the node using

document.getElementById('divData').appendChild(inputFile);

where inputFile is the input type file I create,

it just does not send any of those with the request.

Any more thoughts?
Sorry, this:

> divData.innerHTML = divData + "<input type='file'" + cnt + "'><br>"

is actually

divData.innerHTML = divData + "<input type='file' name='fileName'" + cnt + "'><br>"
I will ask this question in the JavaScript category. Thank you for your help.