Welcome Guest, Not a member yet? Register   Sign In
Jquery Form
#1

[eluser]yorvik[/eluser]
Hello
I am using the UI of jquery to style my form. I want a dialogbox to show up where I can select my files.

The dialogbox is showing up perfect and closing (hiding). But when I submit my form the data of the <input file> doesn't work.

this is my jquery code:
Code:
$(function() {
        $( "#dialog:ui-dialog" ).dialog( "destroy" );
        
        var name = $( "#name" ),
            email = $( "#email" ),
            password = $( "#password" ),
            allFields = $( [] ).add( name ).add( email ).add( password ),
            tips = $( ".validateTips" );
        
        $( "#dialog-form" ).dialog({
            autoOpen: false,
            height: 750,
            width: 750,
            modal: true,
            buttons: {
                "Upload pictures's": function() {
                    $( this ).dialog( "close" );
                        
                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            },
            close: function() {
                allFields.hide();
            }
        });

        $( "#create-user" )
            .button()
            .click(function(e) {
                e.preventDefault();
                $( "#dialog-form" ).dialog( "open" );
            });
    });

I use this html

Code:
<?php
$attributes = array('id' => 'myForm');
echo form_open_multipart('art_controller/add_artwork/', $attributes);
echo '<br /><label for="price">Price: </label>' . form_input('price', set_value('price', 'Price'));
echo '<label for="job">Job: </label>' . form_input('job', set_value('job', 'Job'));
?&gt;
<div id="dialog-form" title="Upload foto's">
<p class="validateTips">Selecteer de foto's die u wil uploaden.</p>

<div>
<label for="file[0]"><strong>FotoAlbum</strong></label>
&lt;input type="file" name="test[0]" class="text ui-widget-content ui-corner-all" /&gt;
</div>
</div>
&lt;/form&gt;
If i don't use the dialog and just show my &lt;input type="file"&gt; on the page everything works fine!

When I submit my form I get the data of price and job correct. But not the data of the file fields. I just hide the dialogbox in my JQuery so I don't get it why the data of my input="file" fields is lost.

Thanks in advance
#2

[eluser]Gerep[/eluser]
When I use something like it, I don't use name="test[0]" but name="test[]".

The Label should be for"test".

I can't see where are you receiving the test[] values or submitting the form.

Sorry if I'm saying stupid things, I'm not so good with JQuery, just trying to help =)
#3

[eluser]yorvik[/eluser]
Well the problem is somewhere in my jQuery. Because if If I don't use the dialog box everything works fine. My file is uploaded en my data has been send to the DB.

But when I use my dialog box and I close it after I selected my file things go wrong..
#4

[eluser]Gerep[/eluser]
Well...I can't say anything now....I would need your code to make some tests =)
#5

[eluser]Atharva[/eluser]
I think you need to add
Code:
Upload pictures's": function() {
                    $( this ).dialog( "close" );
                        $('#myForm').submit();
                },

give it a try.
#6

[eluser]yorvik[/eluser]
Nothing happens when I add this:
Code:
Upload pictures's": function() {
                    $( this ).dialog( "close" );
                        $('#myForm').submit();
                },




Theme © iAndrew 2016 - Forum software by © MyBB