submit buttons inside fancybox

419 views
Skip to first unread message

Lourdes Villanueva

unread,
Jan 18, 2013, 5:33:01 AM1/18/13
to fanc...@googlegroups.com
Hi I have 3 different submit buttons inside a form that is saved in a php file. I have this php file opened inside a fancybox via iframe.

Normally I differentiate the submit buttons by using if(isset($_POST['btnName'])), but here inside the fancybox it doesn't work, does anyone knows why this is not working and how can get this done?
adminJugador.php
verCompletoModificarForma.php

Lourdes Villanueva

unread,
Jan 18, 2013, 5:35:11 AM1/18/13
to fanc...@googlegroups.com
adminJugador.php is the one that invokes verCompletoModificarForma.php which is the file that is opened in fancybox.

JFK

unread,
Jan 18, 2013, 9:10:41 PM1/18/13
to fanc...@googlegroups.com
could you create a sample page with those files and paste the php code here?
I always say to my kids : "don't talk to strangers"
and I always say to myself : "don't download files from strangers"

por favor ;)

Lourdes Villanueva

unread,
Jan 20, 2013, 2:48:23 PM1/20/13
to fanc...@googlegroups.com
hahaha sure!

Here is the part where I call the form to show inside the fancybox and send the POST data:

$("#jugadoresForm").submit(function() {
                $.fancybox.showLoading(); // start fancybox loading animation
                $.ajax({
                    data: $(this).serialize(), // get the form data
                    type: $(this).attr('method'), // GET or POST
                    url: $(this).attr('action'), // the file to call
                    success: function(response) { // on success..
                        $.fancybox({ 'content' : response }); // target response to fancybox
                    },
                    complete: function() { // on complete...
                        $.fancybox.hideLoading(); //stop fancybox loading animation
                    }
                });
                return false; // stop default submit event propagation
            });

I receive all the parameters correctly so no issue here...
Now...in the fancybox with the form I have 3 buttons:
For example this one:
<input type="submit" id="btnModificarJugador" name="btnModificarJugador" value="Guardar" />

And I use an isset function to know which one was submitted:
if(isset($_POST['btnModificarJugador']))
                        {
                            $con = connectDB($host, $user, $password, $db);   
                           
                            $nomCompleto = "".$_POST['txtNombreJugador'];
                            $nomCorto = "".$_POST['txtSNombreJugador'];
                            $fecNac = "".$_POST['txtFechaDeNacimiento'];
                            $luNac = "".$_POST['txtLugarDeNacimiento'];
                            $nac = "".$_POST['drpdwnNacionalidad'];
                            $fecDebut = "".$_POST['txtFechaDeDebut'];
                            $parDebut = "".$_POST['txtPartidoDeDebut'];
                            $p = "".$_POST['txtPeso'];
                            $est = "".$_POST['txtEstatura'];
                            $equ = "".$_POST['drpdwnNombreEquipo'];
                            $pos = "".$_POST['drpdwnPosicion'];
                            $sta = "".$_POST['rdStatus'];
                            $tra = "".$_POST['txtTrayectoria'];
                       
                            updatePlayer($playerID, $nomCompleto, $nomCorto, $fecNac, $luNac, $nac, $fecDebut, $parDebut, $p, $est, $equ, $pos, $sta, $tra);
                           
                            closeConnection($con);
                        }

Well..that doesn't work..it doesn't update my player :(..and no..the function is well written so the updatePlayer function is not the issue.

Fancybox just closes and do nothing... what can I do? :(

JFK

unread,
Jan 20, 2013, 6:27:36 PM1/20/13
to fanc...@googlegroups.com
maybe you don't need to open the form via iframe but ajax or inline otherwise fancybox won't have any control inside the form
check the sample http://fancybox.net/blog No. 5
Reply all
Reply to author
Forward
0 new messages