Hi,

I'm tring to make a simple upload form similar like google has at it's
mail for the atachments. Everything is fine till I try to remove a
file fild that is added at the past with jquery. When I click at the
remove link it still redirects me :(. Can anyone tells me where I'm
wrong. Sorry about the bad English :P.

[CODE]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd";>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
        <title>Multiple Files Uploader</title>

        <?php
            if (isSet($_POST['status'])) {
                foreach ($_FILES as $param)
                    echo '<span id="regular_text">'.$param['name']."</
span><br>";
            }
        ?>

                <style type="text/css">
                        #content {
                                background: #303030;
                                padding: 10px;
                                position: absolute;
                                display: block;
                                border: solid red 1px;
                        }

                        #regular_text {
                                color: red;
                        }

                </style>

        <script type="text/javascript" src="js/jquery-1.3.js"></
script>

        <script type="text/javascript">
           $(function(){
                $("input#submit").hide();
                var i=1;

                $("a#add").click(function(){
                                        $(this).before('<p id="added' + i + 
'"><input type="file"
name="file_' + i + '" id="fileupload"/>&nbsp;&nbsp<a
href="nofile.html" id="remove">[remove]</a></p>');
                    if (i==1) {
                        $("input#submit").show();
                        //console.log($("a#remove").parent().get(0));
                    }
                    i++;
                    return false;
                });

                $("a#remove").click(function(){
                                        $parent = $(this).parent().get(0);
                                        $parent.remove();
                                        return false;
                });
            });
        </script>

    </head>
    <body>
        <form enctype="multipart/form-data" action="#" method="POST"
id="multiForm">
        <div id="content">
            <strong><span id="regular_text">Select files ot upload:</
span></strong><br />
            <!--<input type="file" name="file_1" id="fileupload"/><br /
>-->
            <a href="index.php" id="add">[add file]</a><br />
            <input type="submit" value="Upload Files" id="submit"/
><br />
            <input type="hidden" name="status" value="1" />
        </div>
        </form>
    </body>
</html>

[/CODE]

Regards

Reply via email to