| Issue 412: | trying to get nyromodal working when the form is generated by javascript | |
| 2 people starred this issue and may be notified of changes. | Back to list |
|
hello,
I have a bunch of forms on my page which must be submitted at once (no
other choice).
To do so, I scripted this in javascript:
<script type="text/javascript">
function submitFormsById(arrayDIdDeForms)
{
var grosForm = document.createElement("form");
with(grosForm)
{
method = "POST";
action = "private/scripts/jquery/nyromodal/finalise_groupe_add.php";
ClassName="nyroModal"
name = "grosForm";
id = "grosForm";
style.display = "none";
}
for(var i=0;i<arrayDIdDeForms.length;i++)
{
appendFormVals2Form(document.getElementById(arrayDIdDeForms[i]), grosForm);
}
document.body.appendChild(grosForm);
grosForm.submit();
}
function appendFormVals2Form(petitForm, formConteneur)
{
var elements = petitForm.elements;
for(var o=0;o<elements.length;o++)
{
var element=elements[o].cloneNode(true);
element.value=elements[o].value;
formConteneur.appendChild(element);
}
return formConteneur;
}
"
the "appendFormVals2Form" function allows me to collect all the forms
values while the "submitFormsById()" function allows me to generate a brand
new form, assign all my values to it and submit it.
On the html side, for each individual form, I have this:
<form action="..." method="post" id="form<?php echo $x; ?>">
and at the end of the page, I have a "submit" input (but no form around):
<input type="submit" value="..." name="..."
onClick="submitFormsById(Array(<?php while ($z<=$nombre_elements){if
($z==$nombre_elements) {echo "'form".$z."'";} else {echo "'form".$z."',";};
$z++;} ?>))">
This script works perfectly but opens a brand new window instead of using
the nyromodal script.
I cannot surround my last standalone submit input with a nyromodal form as
the form is already generated by my javascript. If I do so, I have the
nyromodal effect but a double submit which prevents me from collecting my
values.
I just don't get why I cant get the nyromodal effect to work in javascript
even if I specify "className='nyroModal'...
Is there any workaround or am I doing wrong?
Thank you
Jan 16, 2010
#2
lexgot...@gmail.com
Jan 16, 2010
Yes, it won't work because the binding is done at the load page. To solve it, you can do something like: $(grosForm).nyroModal().submit(); instead of your current submit line.
Jan 16, 2010
Perfect! Thank you very much nyrodev.
Jan 16, 2010
don't hesitate to send the link of your website when it's live. Issue closed ;)
Status:
Fixed
|
||||||||