I have the follow code. And what I like to have, is, the value from the select1 in the 2. Form, input "girl" value. But I do not know, how to do... I always have an empty value in the 2. form.

    <?php
            mysql_connect("localhost:8888", "root", "root") or die("Connection Failed");
            mysql_select_db("usr_web202_9")or die("Connection Failed");
            $query = "SELECT idgirls,name FROM girls";
            $result = mysql_query($query);
        ?>
        <form name="formName" method="post" action="">
        <select name"select1" onchange="formName.submit()">
        <?php
        while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        ?>
        <option value="<?php echo $line['idgirls'];?>"> <?php echo $line['name'];?> </option>

        <?php
        }
        ?>
        </select>
        </form>

    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="userfile" class="fileUpload" multiple>
    <input type="hidden" name='girl' value='<?php echo $_GET['select1'];?>' />

        <button id="px-submit" type="submit">Upload</button>
        <button id="px-clear" type="reset">Clear</button>
</form>
    <script type="text/javascript">
        jQuery(function($){
            $('.fileUpload').fileUploader();
        });
    </script>

Hope, somebody can help me. It is my key to continue my project...

Recommended Answers

All 7 Replies

coz you are trying to get from _GET, and the first form is using POST
try changing to <input type="hidden" name='girl' value='<?php echo $_POST['select1'];?>' />

It's not work. If I change the "select" I mean to the 2. option, it's change quickly back to the first option. And still no value, where I like to have.

Maybe important to tell, both form's are in the same file.

did u changed $_GET['select1'] to $_POST['select1'] ?

try giving them different form names like form name="form1" and form name="form2"
also u have = forgoten in the first form
<select name"select1" onchange="formName.submit()">
it should be
<select name="select1" onchange="formName.submit()">

I am nearly there, where I like to be. With the code like this. The only problem I have, when I start the url, I allready have the value '2' inside. It's not change anything. What it could be?

Should I put something with ifset in the top of page?

<?php
            mysql_connect("localhost:8888", "root", "root") or die("Connection Failed");
            mysql_select_db("usr_web202_9")or die("Connection Failed");
            $query = "SELECT idgirls,name FROM girls";
            $result = mysql_query($query);
        ?>
        <form name="form1" method="post" action="">
        <select name='select1' onchange="formName.submit()">
        <?php
        while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        ?>
        <option value='<?php echo $line['idgirls'];?>'> <?php echo $line['name'];?> </option>

        <?php
        }
        ?>
        </select>
        </form>
    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <form name="form2" action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="userfile" class="fileUpload" multiple>
    <input type="hidden" name='girl' value='<?php echo $_POST['select1'];?>' />

        <button id="px-submit" type="submit">Upload</button>
        <button id="px-clear" type="reset">Clear</button>
</form>

there are errors in your code

 <select name='select1' onchange="formName.submit()">

It should be

 <select name='select1' onchange="form1.submit()">//the name of the form

I allready changed this, but still not better. Still the problem, if I change the dropdown, I have the 'value' 2.

Or maybe You can advise me, how I can do. In the end, the user need to choose one girl from a list, and I need the girl-id for later on a another document.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Uploader</title>
<link href="css/reset.css" rel="stylesheet" type="text/css" />

<style type="text/css">
body {
    margin: 10px;
    font: 62% Tahoma, Arial, sans-serif;
}
#main_container{
    font-size: 1.4em;
}
h2 {
    font-size: 2em;
    padding-bottom: 20px;
}
</style>

<link href="css/ui-lightness/jquery-ui-1.8.14.custom.css" rel="stylesheet" type="text/css" />
<link href="css/fileUploader.css" rel="stylesheet" type="text/css" />

<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script>
<script src="js/jquery.fileUploader.js" type="text/javascript"></script>

</head>

<body>
<div id="main_container">
    <h2>Bilder Girls Uploader</h2>
    <p>&nbsp;</p>
    <p>

    <?php
            mysql_connect("localhost:8888", "root", "root") or die("Connection Failed");
            mysql_select_db("usr_web202_9")or die("Connection Failed");
            $query = "SELECT idgirls,name FROM girls";
            $result = mysql_query($query);
        ?>
        <form name="form1" method="post" action="index.php" onselect="this.submit();">
        <select name='select1' onchange="form1.submit()">
        <?php
        while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        ?>
        <option value='<?php echo $line['idgirls'];?>'> <?php echo $line['name'];?> </option>

        <?php
        }
        ?>
        </select>
        </form>
    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <form name="form2" action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="userfile" class="fileUpload" multiple>
    <input type="hidden" name='girl' value='<?php echo $_POST['select1'];?>' />

        <button id="px-submit" type="submit">Upload</button>
        <button id="px-clear" type="reset">Clear</button>
</form>
    <script type="text/javascript">
        jQuery(function($){
            $('.fileUpload').fileUploader();
        });
    </script>
</div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.