|
PassingFormValues
IntroductionFor example we have the following form on one MB page: <form action="yoururl.php" method="get" id="myform" onsubmit="return false">
</form> and then in youurl.php we're doing the following: <?php $name = $GET['name']; $email = $GET['email'];?> <?php echo $name ?>, your message sent!to show the sender name. That's all! DetailsSee the working example here: http://okonet.ru/projects/modalbox/ Please note: http://prototypejs.org/api/form/serialize |
► Sign in to add a comment
Verry cool, but have to read a lot to get it i quess;) iI think it's wurth that!
Is there a way to change the method from GET to POST? I tried:
Doesn't work...
Is there a way to change the method from GET to POST? I tried:
Doesn't work...
Is there a way to change the method from GET to POST? I tried:
Doesn't work...
I think the order of the "show(" argument's are given regarding the previous release. The url of the next modalbox should be the the first one.
try
method: 'post'
any idea how to post multipart MIME? our form has a field for uploading a picture but the MB requests are url-encoded. Any help would be great.
TIA, -gt
It doesn't work to me. Is there any update that breaks it? I get to yoururl.php but i can't get the params. It also tried with : $('myform').serialize(true) instead of : Form.serialize('myform') I just can't make it work!!! Any help there? regards, juanfra
the way to call it is Modalbox.show('yoururl.php', {params: Form.serialize('myform') }); return false;
Not Working
It's working on the demo page here: http://wildbit.com/labs/modalbox/
Corrected Text
and then in yoururl.php we're doing the following: <?php $name = $_GET['name']; $email = $_GET['email']; ?> <h1><?php echo $name ?>, your message sent!</h1>Could use www.gettopost.com/gettopost.html to do the GET to POST conversion?
I can get $POST's to work for <input type="text"> but CAN'T for <input type="file"> Is there a way to do this? Is there a param spot for enctype="multipart/form-data"? TIA
I was having this problem with a form. What fixed things for me was to add an "id" tag to the form declaration.
(sorry for my english, but i speak spanish) in this example the form is put into a modalbox o a normal window????
i trie tu put a form into modalbox to send data to the same modalbox (or another)... this example works for send data to the normal window to modalbox, but i can't send data to the form on modalbox to modalbox... how can i get it??
$GET works, but is there a way to automatically close the the box after success? (I'm guessing maybe DOM?)
Hello, i need to send my data via $POST, what i need to change and where?
thanks a lot
and what about instead of the action being a 'yoururl.php' it is a <?php echo $somevariable ?>, how would you make the messages contained within that variable appear in the next modalbox?
I am opening a LOGIN textbox and password field in the modal window(Actually my PHP page). After submitting of the data using POST, i want to display WELCOME page in same modal window...
Is it possible.. ?
For the POST version it works I do that : <form id="formulaire" action="url.php" method="post" onsubmit="return false;"> ... <input type="submit" title="TITRE" value="Show" onclick="Modalbox.show('url.php', {title: this.title, method: 'post', params:Form.serialize('formulaire'), overlayClose: true }); return false;" class="formulaire" /> </form>
It works fine :)
Yeah this script from paul with POST worked for me too!!! Thx really much paul!!!
i got problem too with <input type="file"> Is there a way to do this? Is there a param spot for enctype="multipart/form-data"?
to answer a few of your questions re file uploads:
This cannot be done because modalbox uses Prototype's Ajax.Request function which does not allow uploads.
There is another solution though: look into SwfUpload? - http://swfupload.org/
I am struggling with the wizard function. I have a form in the modalbox. When I click the button, I want to pass the variables of the form to itself and then repaint the modalbox with the changes. I am running PHP on the back side. It seems like this should be possible, but when calling ...
<button type="button" onclick="Modalbox.show('Making changes', 'sameAsOriginalPage.php', {width: 600, height:650}); return false;"><< Remove selected users from group</button>
The box shrinks and just stays there. What am I doing wrong?
Mike
dynamic content/form elements is not included when submitting the form using modalbox
I am trying to submit a contact form. I have tried a number of things, but I am not able to get the form to submit (email). It will either submit the form, or continue to the yoururl.php, but I cannot get it to do both submit and move to the yoururl.php page.
Any help would be great.
Here is the code I am using for the form:
<form id="form" name="form" method="post" action="forms/process.php"> <label>Name <span class="small">Add your name</span> </label> <input type="text" name="Name" id="name" />
<label>Email <span class="small">Add a valid address</span> </label> <input type="text" name="Email" id="email" />
<label>Phone <span class="small">Min. size 10 chars</span> </label> <input type="text" name="Phone" id="phone" />
<label>Message <span class="small">Leave a message</span> </label> <textarea name="Message" class="mytextarea" id="message"></textarea>
<button type="button" value="Submit" onclick="Modalbox.show('forms/yoururl.php', {title: 'Sending status', params: Form.serialize('myform') }); return false;" />Submit</button>
good stuff. thanks!
I had a prolbem using it, so I tired this :
Modalbox.show(this.href, {title: this.title, width: 600, method: 'post', params: inscriptionCB.serialize(), overlayClose: true }); return false;
Note that I used inscriptionCB.serialize() instead of Form.serialize('inscriptionCB') (inscriptionCB is the name of my form).
Hoping it will help somebody.
Oh sorry, this tricks works onl with Firefox. Finally I used : Modalbox.show('inscriptionCB_commentaire.php',{title: 'Commentaire envoyé', width:600, method: 'post', params: Form.serialize(inscriptionCB_ajoutCommentaire), overlayClose: true})
Note the "Form.serialize(inscriptionCB_ajoutCommentaire)"
thaks alot
hi, i have a select field in my modal box. but it is a form that should be filled and updates the database. Any idea on how to do this. the select is not being fetched
Value of FCKeditor don't work! :/
Yep the POST Method works ...
<input type="submit" value="Visualizar o relatório"
Tks a lot!
Does anyone know how to do form validation on modal box? I tried many things but nothing worked, I see in the demo email validation is in place. Please please please help...
Hi everyone... i was the same problem... and test, and test, and teste, and test... and teste angain, and again, and again.... in the end i think to do work. (sorry by my english. I speak only Spanish and portugues )
My solutions:
index.php
<a href="formSend.php" title="Titulo da barra" onclick="Modalbox.show(this.href, {title: this.title, width: 600}); return false;"> OPEN </a>
formSend.php
<form id="form" name="form" method="post" action=""> <label>Name </label> <input type="text" name="Name"/> <label>Message </label> <textarea name="Message"></textarea> <button type="button" value="Submit" onclick="Modalbox.show('formRecive.php', {title: 'Sending status', params: Form.serialize('form') }); return false;" />Submit</button> </form>formRecive.php
--- if anyone get nice results, please write me. ---
Here is a working procedure to really use a FCKeditor inside a Modalbox :
I will use 2 files. One from which the modalbox is defined, and one wich be called inside the Modalbox, and will contain the FCKEditor.
First call of the Modalbox
The Modalbox is called with a button where i put a onclick instruction :
onclick="Modalbox.show('solutions.php', {title: this.title, method: 'POST', params: {id: '<? echo $id; ?>'} }); return false;"So the Modalbox is created, with solution.php called inside, and the 'id' value sended to by POST.
Integration of FCKEditor inside of the modalbox
In solution.php there is a form who send the datas to itself.
<form action="#" method="POST" name="solution-form" id="solution-form" accept-charset="utf-8" onsubmit="Modalbox.show('solutions.php', {title: 'FCKEditor integration', width: 500, params:Form.serialize('solution-form'),overlayClose: true }); return false;">params: Form.serialize('form') is supposed to get all input values of the form.
I created my FCKEditor in the PHP way:
<?php $oFCKeditor = new FCKeditor('solution') ; $oFCKeditor->BasePath = '/fckeditor/' ; $oFCKeditor->Value = $_POST['solution'] ; $oFCKeditor->Create() ; ?>as described here: http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Integration/PHP
If you create a FCKEditor called 'solution', it will create an iframe with the rich editor, and an hidden input with this name:
The FCKEditor code is supposed to attribute the content of the iframe to this hidden input, but there is a conflict between FCKEditor and Modalbox codes so this hidden input can not take value of the FCKEditor iframe.
As a consequence, params: Form.serialize('form') of the Modalbox is unable to get the value of the FCKEditor because the hidden input remains empty, and you have an error saying ='FCK is not defined in fckeditorcode_gecko.js on line 31'.
So we will force the value of the hidden field in javascript before submit the form, using the FCKEditor API.
So in my form, on the submit button i add this code (in my case the hidden field is called 'solution':
onclick="javascript:document.getElementById('solution').value=FCKeditorAPI.GetInstance('solution').GetXHTML();"Source (in french): http://www.tayo.fr/fckeditor-ajax-recuperer-texte-astuce.php
So when I click on submit, the FCKEditor API put the content of the FCKEditor iframe as a value of the hidden input 'solution' created by the FCKEditor, and on this allow params: Form.serialize('form') to get it correctly.
On the php side i can get this value with a classical :
I hope that my explanations are clear (french speaking here), and that they can help.
Well I have tried each and every suggestion. I think the developer ought to get a solution and post it with which browsers he has tested it on. I can't get it to work and by the number of other comments I'm not alone. But some people have gotten it to work, but it seems much to unreliable to be trusted.