0

Hi All, I have code that dynamically retrieves data with jquery AJAX. when i want to insert data into database via PHP $_POST method it cannot grab select tag (option) value in Mozilla and Chrome. But it works perfectly in IE.
Below is my code.

<?php
if($_GET['func'] == "drop_1" && isset($_GET['func'])) { 
   drop_1($_GET['drop_var']); 
}  
function drop_1($drop_var)
{  
        include_once('db.php');
    $tablet='table'.$drop_var;
    $active='active';
        $result = mysql_query("SELECT * FROM $tablet where mid='$drop_var' AND act='$active'") or die(mysql_error());
    echo '<div class="styled-select">';
    echo '<select name="region"><option value="bir" disabled="disabled" selected="selected">Secin...</option>';
           while($drop_2 = mysql_fetch_array( $result )) 
            {
              echo '<option value="'.$drop_2['id'].'">'.$drop_2['name'].$drop_2['id'].'</option>';
            }

    echo '</select>';
    echo '</div>';
    }


    ?>

Edited by Dani: Fixed formatting

3
Contributors
6
Replies
9
Views
5 Years
Discussion Span
Last Post by Biiim
0

From what I can see this just shows a dropdown. Where does the get data come from? Also it seems your not using a form. Is this dropdown/select controlled by JQuery?? Show your code.

0

Thank you for attention

submenu.php

<?php
if($_POST){ foreach($_POST as $key=>$value){ $$key=$value;} }
if(isset($_POST['addmenu'])){
    if($drop_1!="bir" && $_POST['region']!="bir"){

    $values="values('', '$secim', '$drop_1', '".$_POST['region']."', '$menu')";
    $nactive='nactive';
    $table='table'.$drop_1;
    $func->seher('submenular', $values);
    mysql_query("UPDATE $table SET act='".$nactive."' where id='".$_POST['region']."'");

    Header("Location: index.php?do=addsubmenu");
}
}

?>

<table border=0 width="100%">
 <form method="post" action="">
            <tr><td colspan=2><center>AZ</center></td></tr>
            <tr><td>Menyu tipi</td><td><div class="styled-select"><select name="secim">
            <?php
            $yazi=mysql_query("Select * from menular");
                $men=$func->netice($yazi);
foreach($men as $neticeler){
    echo '<option value="'.$neticeler['id'].'">'.$neticeler['menu'].'</option>';



} ?></select></div></td></tr>
                <tr><td>Stil</td><td><div class="styled-select">
             <select name="drop_1" id="drop_1">
            <option selected value="bir">sec...</option>
            <option value="1">uc sutun</option>
            <option value="2">Iki sutun</option>
            <option value="3">Champ</option>
            <option value="4">Drivers</option>
            <option value="5">Qalereya</option>
            <option value="6">Arxive Xeber</option>
            </select></div>
            </td></tr>
            <tr><td  width="161"> Title:</td><td  width="161"><div class="styled-select"><input type="text" name="title" value=""></div></td></tr>

                    <tr><td><span id="wait_2" style="display: none;">Secim:</span></td><td><span id="wait_1" style="display: none;">
                <img alt="Please Wait" src="ajax-loader.gif"/>
            </span>
            <span id="result_1" style="display: none;"></span> </td></tr>
            <tr><td width="161"> Menyunun adi</td><td width="161" ><div class="styled-select"><input type="text" name="menu" value=""></div></td>
</tr>
<tr><td><div class="styled-select"><input type="submit" value="daxil et" name="addmenu"></div></td><td></td></tr>

  </form>
    </table>
</div>

and index.php

<?php
session_start(); 
ob_start();
include('config/connect.php');
include("spaw.inc.php");
$func=new funksiyalar();

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    >
<html>
<head>
   <title></title>
   <style>
   .rightsidenav{
background:
        -webkit-gradient(
            linear,
            left top,
            left bottom,
            from(#800000),
            to(#F00)
        );
    background:
        -moz-linear-gradient(
            top,
            #800000,
            #F00
        );
        background-color:#800000;
    -moz-border-radius-topright:5px;
   -webkit-border-top-right-radius:5px;
    border-top-right-radius:5px;
   -moz-border-radius-topleft:5px;
   -webkit-border-top-left-radius:5px;
   border-top-left-radius:5px;
    -moz-box-shadow:1px 1px 3px #111;
    -webkit-box-shadow:1px 1px 3px #111;
    box-shadow:1px 1px 3px #111;
    width:180px;
    height:35px;
    display:block;
    position:relative;
}
.rightsidenav h2{
    font-size:18px;
    font-family:Arial, Tahoma, Helvetica;
    color:#fff;
    padding:3px 0px 5px 0px;
    text-align:left;
    font-style:italic;
}
   #isare, #isare1, #isare2, #isare3, #isare4 {
   margin-top:10px;
   margin-left:10px;
   }
 #cont1 a, #cont2 a, #cont3 a, #cont4 a, #cont5 a { font-family: Tahoma,Lucida Sans Unicode; color: #000000; font-size: 13px; font-weight: bold; margin-left:10px; text-decoration:none}
#bir a:hover {color: #ffffff; font-style: normal; text-decoration:underline}

   </style>

   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <link type="text/css" href="style.css" rel="stylesheet" />
<link type="text/css" href="style1.css" rel="stylesheet" />
        <script type="text/javascript" src="jquery-1.4.1.min.js"></script>
         <script>

          $(document).ready(function() {
                $('#wait_1').hide();
                $('#drop_1').change(function(){
                $('#wait_2').hide();
                $('#wait_2').show();
                $('#wait_4').hide();
                $('#result_2').hide();
                $.get("func.php", {
                func: "drop_1",
                drop_var: $('#drop_1').val()
                }, function(response){
                $('#result_1').fadeOut();
                setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
                });
                return false;
                });
                });

                function finishAjax(id, response) {
                $('#wait_1').hide();
                $('#'+id).html(unescape(response));
                $('#'+id).fadeIn();
                }
                function finishAjax_tier_three(id, response) {
                $('#wait_3').hide();
                $('#'+id).html(unescape(response));
                $('#'+id).fadeIn();
                }
                function finishAjax_tier_four(id, response) {
                $('#wait_5').hide();
                $('#'+id).html(unescape(response));
                $('#'+id).fadeIn();
                }
   </script>
   <script>
   var glob=true;
   var glob1=true;
   var glob2=true;
   var glob3=true;

        $(function() {

            /*  $('.men').click(function() {
                $('.ldd_submenu').slideDown("300px");
           //     $(this).animate({ "width" : "50px" }, 4000);
        }); */
         $('.ana').click(function() {
         if(glob==true){
                $('#cont1').slideDown();
                $('#isare').attr('src','simbol/minus.png');
                glob=false;
                }
                else {
                $('#cont1').slideUp();
                $('#isare').attr('src','simbol/sign.png');
                glob=true;
                }

        });
                 $('.champ').click(function() {
                 if(glob1==true){
                 $('#cont2').slideDown();
                 $('#isare1').attr('src','simbol/minus.png');
                 glob1=false;
                 }
                 else {

                $('#cont2').slideUp();
                $('#isare1').attr('src','simbol/sign.png');
           glob1=true;
           }
        });
             $('.video').click(function() {
                 if(glob2==true){
                 $('#cont4').slideDown();
                 $('#isare2').attr('src','simbol/minus.png');
                 glob2=false;
                 }
                 else {

                $('#cont4').slideUp();
                $('#isare2').attr('src','simbol/sign.png');
           glob2=true;
           }
        });

  $('.gual1').click(function() {
                 if(glob3==true){
                 $('#cont5').slideDown();
                 $('#isare4').attr('src','simbol/minus.png');
                 glob3=false;
                 }
                 else {

                $('#cont5').slideUp();
                $('#isare4').attr('src','simbol/sign.png');
           glob3=true;
           }
        });


 });



   </script>
    <style>
.menu {

list-style:none;

}

</style>

        </head>
        <body>
                <div id="esas" class="esas">
                    <div id="banner"></div>
                    <div id="menyular">
                        <div id="bir" class="bir">
                        <div class="rightsidenav"><div class="ana"><img src="simbol/sign.png" height="10px" id="isare" style="margin-right:25px; float:left"></div><h2>Ana Səhifə</h2></div>
<div id="cont1" style="display:none; margin-bottom:5px;">        <a href="?do=addmenu">Menu əlavə et</a><br>
                        <a href="?do=addsubmenu">Submenu əlavə et</a><br>
                        <a href="?do=addsekil">Sekil əlavə et</a><br>
                        <a href="?do=addxeber">Xeber əlavə et</a><br>
                        <a href="?do=clip">Video əlavə et</a><br>
                        <a href="?do=addinter">Intervyu əlavə et</a><br>
                        <a href="?do=newsmid">Orta Blok xeber</a>
                        </div>
                        <div class="rightsidenav"><div class="champ"><img src="simbol/sign.png" height="10px" id="isare1" style="margin-right:25px; float:left"></div><h2>Çempionatlar</h2></div>
                        <div id="cont2" style="display:none; margin-bottom:5px;"><a href="?do=champ">Çempionat siyah Əlavə et</a><br>
                        <a href="?do=list">Siyahi Əlavə et</a><br>
                        <a href="?do=driver">Sürücü Əlavə et</a><br>
                        <a href="?do=champ1">Çempionat Əlavə et</a></div>
                        <div class="rightsidenav"><div class="arxiv"><img src="simbol/sign.png" height="10px" id="isare3" style="margin-right:25px; float:left"></div><h2>Arxiv</h2></div>
                        <div class="rightsidenav"><div class="video"><img src="simbol/sign.png" height="10px" id="isare2" style="margin-right:25px; float:left"></div><h2>Video bölməsi</h2></div>
                        <div id="cont4" style="display:none; margin-bottom:5px;"><a href="?do=gallery">Qalereya Əlavə et</a><br>
                        <a href="?do=gallist">Qalereya listi Əlavə et</a></div>
                        <div class="rightsidenav"><div class="gual1"><img src="simbol/sign.png" height="10px" id="isare4" style="margin-right:25px; float:left"></div><h2>Qualifing</h2></div>
                            <div id="cont5" style="display:none; margin-bottom:5px;"><a href="?do=gual">Əlavə et</a><br>
                            <a href="?do=race">Race Əlavə et</a><br>
                            <a href="?do=grid">Grid Əlavə et</a><br>
                            <a href="?do=practice">Practice Əlavə et</a><br>
                            </div>
                        </div>
                <div id="bir" style="width:160px;margin-top:20px;height:250px">
                     <strong><a href="?do=menushow">Menular</a></strong><br>
                     <a href="?dos=logout"><strong>Cixis</strong></a><br>
                    </div>
                    </div>
                    <div id="merkez">
                    <?php
                    $include="";
                    if(isset($_GET['do']) && $_GET['do']=="addmenu"){
                    $include='menu';

                    }
                    else if(isset($_GET['do']) && $_GET['do']=="addsubmenu"){
                    $include='submenu';
                    }
                    else if(isset($_GET['do']) && $_GET['do']=="addxeber"){
                    $include='xeber';

                    }
                    else if(isset($_GET['do']) && $_GET['do']=="addinter"){
                    $include='interview';

                    }
                        else if(isset($_GET['do']) && $_GET['do']=="menushow"){
                    $include='menushow';

                    }
                    else if(isset($_GET['do']) && $_GET['do']=="clip"){
                    $include='clip';

                    }
                    else if(isset($_GET['do']) && $_GET['do']=="list"){
                    $include='list';

                    }
                    else if(isset($_GET['do']) && $_GET['do']=="driver"){
                    $include='driver';

                    }
                        else if(isset($_GET['gid']) && (isset($_GET['esas1']) && $_GET['cont1']==3)){
                    $include='champ_edit';

                    }
                        else if(isset($_GET['gid']) && (isset($_GET['esas1']) && $_GET['cont1']==5)){
                    $include='gallery_edit';

                    }
                        else if(isset($_GET['do']) && $_GET['do']=="gallist"){
                    $include='gallist';

                    }
                    else if(isset($_GET['do']) && $_GET['do']=="newsmid"){
                    $include='newsmid';

                    }
                        else if(isset($_GET['do']) && $_GET['do']=="gual"){
                    $include='gual';

                    }
                    else if(isset($_GET['do']) && $_GET['do']=="champ"){
                    $include='champ';
                    }
                    else if(isset($_GET['do']) && $_GET['do']=="champ1"){
                    $include='champ1';
                    }
                    else if(isset($_GET['do']) && $_GET['do']=="gallery"){
                    $include='gallery';
                    }
                    else if((isset($_GET['do']) && $_GET['do']=="addsekil") || (isset($_GET['sekil']) && $_GET['sekil']!="")){
                    $include='picture';

                    }
                    else if(isset($_GET['do']) && $_GET['do']=="grid"){
                    $include='grid';
                    }
                    else if(isset($_GET['do']) && $_GET['do']=="race"){
                    $include='race';
                    }
                    if(isset($_GET['menu']) && $_GET['menu']!=""){
                    $menu='menuedit';

                    }
                    $include_file='includes/'.$include.'.php';
                    if(file_exists($include_file)){
                    include($include_file);
                    }
                    else {

                    echo 'Bele kontent movcud deyil. heleki )))';

                    }
                    ?>
                    </div>
                    </div>
                    </body>
                    </html>
<?php
ob_end_flush();

?>

Edited by azegurb

0

I formatted the js:

$(document).ready(function() {
    $('#wait_1').hide();
    $('#drop_1').change(function(){
        $('#wait_2').hide();
        $('#wait_2').show();
        $('#wait_4').hide();
        $('#result_2').hide();
        $.get("func.php", {
            func: "drop_1",
            drop_var: $('#drop_1').val()
        }, function(response){
            $('#result_1').fadeOut();
            setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
        });
        return false;
    });
});
function finishAjax(id, response) {
    $('#wait_1').hide();
    $('#'+id).html(unescape(response));
    $('#'+id).fadeIn();
}
function finishAjax_tier_three(id, response) {
    $('#wait_3').hide();
    $('#'+id).html(unescape(response));
    $('#'+id).fadeIn();
}
function finishAjax_tier_four(id, response) {
    $('#wait_5').hide();
    $('#'+id).html(unescape(response));
    $('#'+id).fadeIn();
}
var glob=true;
var glob1=true;
var glob2=true;
var glob3=true;
$(function() {
    $('.ana').click(function() {
        if(glob==true){
            $('#cont1').slideDown();
            $('#isare').attr('src','simbol/minus.png');
            glob=false;
        }else{
            $('#cont1').slideUp();
            $('#isare').attr('src','simbol/sign.png');
            glob=true;
        }
    });
    $('.champ').click(function() {
        if(glob1==true){
            $('#cont2').slideDown();
            $('#isare1').attr('src','simbol/minus.png');
            glob1=false;
        }else{
            $('#cont2').slideUp();
            $('#isare1').attr('src','simbol/sign.png');
            glob1=true;
        }
    });
    $('.video').click(function() {
        if(glob2==true){
            $('#cont4').slideDown();
            $('#isare2').attr('src','simbol/minus.png');
            glob2=false;
        }else{
            $('#cont4').slideUp();
            $('#isare2').attr('src','simbol/sign.png');
            glob2=true;
        }
    });
    $('.gual1').click(function() {
        if(glob3==true){
            $('#cont5').slideDown();
            $('#isare4').attr('src','simbol/minus.png');
            glob3=false;
        }else{
            $('#cont5').slideUp();
            $('#isare4').attr('src','simbol/sign.png');
            glob3=true;
        }
    });
});

I notice is $.get("func.php", { you say you want to post not get?

And the function says $('#drop_1').change(function(){ , this means any element on the page with an id of 'drop_1', so you need to add it to the select box:

<select name="region" id="drop_1">
0

thank you very much. but Native POST method cannot get value of the second jquery generated select box ("echo '<select name="region"><option value="bir" disabled="disabled" selected="selected">")
it works perfect in IE. but it doesnt work in Mozilla and Chrome. Why?

echo '<select name="region"><option value="bir" disabled="disabled" selected="selected">

0

can you output the html code that the php generates?

It could be that theres a javascript error - i know chrome halts on a javascript error and wont run where as ie is more lenient

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.