SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I couldn't Post Dropdown list value from some page to another by JQuery in PHP

    Hello all
    I have some web site contains some PHP pages and there's some page contains dropdown list and when I select some item from it I want to post it to another page by Jquery to used it, but it doesn't and I get the following error message
    "Notice: Undefined index: opts in C:\htdocs\icare\php\reservation.php on line 4"

    the Page which contains the drop down is as the following:
    PHP Code:
    <?php
    session_start
    ();



    require_once 
    'locale.php';
    include_once 
    "security.php";
    include_once 
    "dicom.php";
    include_once 
    "tabbedpage.php";
    require_once 
    "header.php";
    include_once(
    'main.php');
    ?>
    <html>

    <head>

    <meta http-equiv="content-type" content="text/html;charset=utf-8">

    <noscript><meta http-equiv="refresh" content="0; url=error.php?error_code=2"></noscript>

    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/jquery-cookies.js" type="text/javascript"></script>
    <script src="js/jquery-base64.js" type="text/javascript"></script>
    <script type="text/javascript">
    function makeAjaxRequest(opts){
            $.ajax({
              type: "POST",
              data: { opts: opts },
              url: "reservation.php",
              success: function(res) {
                //$("#results").html("<p>$_POST contained: " + res + "</p>");
              }
            });
          }

          $("#modalityid").on("change", function(){
            var selected = $(this).val();
            makeAjaxRequest(selected);
          });        
        </script>
    <?php
    //echo"-------".$_POST[selectedid];
    include('js/header-js.php');
     
    ?>
    <script src="js/main.js" type="text/javascript"></script>

    <link href="css/style.css" rel="stylesheet" type="text/css">
    <link rel="shortcut icon" href="img/favicon.ico">

    <title>Patien Work List</title>

    </head>

    <body>
    <div id="notification_div"><div id="notification_inner_div"><div id="notification_inner_cell_div"></div></div></div>

    <div id="header_div">
    <?php 
    $result1 
    $dbcon->query("SELECT id,name,code,description FROM modality");
        echo 
    "<center>Modality :";    
        echo 
    "<select name='modalityid' id='modalityid' class='input-reg' onchange='sendID(this.value)'>";
                echo
    "<option value='0'>select item</option>";
                
            while(
    $row1 $dbcon->fetch_array($result1))//, "ASSOC"))
            
    {
                      unset(
    $id$name);
                      
    $id1 $row1['id'];
                      
    $name1 $row1['name'];
                        if (
    $row1['id'] == $climodality)
                        echo 
    "<option  value='$id1' selected >$name1</option>";
                        else 
                        echo 
    "<option  value='$id1' >$name1</option>";

                }

        echo 
    "</select></center>";


    include(
    'headerrsv.php'); 
    //include('reservation.php'); 
    ?></div>

    <h1><?php echo global_title?></h1>
    <h2><?php echo global_organization?></h2>

    <div id="content_div"></div>

    <div id="preload_div">
    <img src="img/loading.gif" alt="Loading">
    </div>


    <?php
    require_once "footer.php";
    ?>
    </body>

    </html>

    and the page which have to receive the posted value is as the following:
    PHP Code:
    <?php

    echo '<pre>'
      
    print_r($_POST['opts']);
      echo 
    '</pre>';

    session_start();

    require_once 
    'locale.php';
    include_once 
    'database.php';
    include_once 
    'sharedData.php';

    include_once(
    'main.php');



    global 
    $PRODUCT;
    $dbcon = new MyConnection();
    //if(isset($_POST[selectedid]))
    if(isset($_GET['make_reservation']))
    {
        
    $week mysql_real_escape_string($_POST['week']);
        
    $day mysql_real_escape_string($_POST['day']);
        
    $time mysql_real_escape_string($_POST['time']);
        
        echo 
    make_reservation($week$day$time);
    }
    elseif(isset(
    $_GET['delete_reservation']))
    {
        
    $week mysql_real_escape_string($_POST['week']);
        
    $day mysql_real_escape_string($_POST['day']);
        
    $time mysql_real_escape_string($_POST['time']);
        echo 
    delete_reservation($week$day$time);
    }
    elseif(isset(
    $_GET['read_reservation']))
    {
        
    $week mysql_real_escape_string($_POST['week']);
        
    $day mysql_real_escape_string($_POST['day']);
        
    $time mysql_real_escape_string($_POST['time']);
    //if(isse/t($_POST[selectedid]))
    echo"---------".$_Session['modalitySelected'];

        
    //if($_POST[selectedid])
        
    $modalityid=1;//$_POST[selectedid];
        //echo "-------".$_POST[selectedid];
        
        
        
    echo read_reservation($week$day$time,$modalityid);

    }
    elseif(isset(
    $_GET['read_reservation_details']))
    {
        
    $week mysql_real_escape_string($_POST['week']);
        
    $day mysql_real_escape_string($_POST['day']);
        
    $time mysql_real_escape_string($_POST['time']);
        
        echo 
    read_reservation_details($week$day$time);
    }

    elseif(isset(
    $_GET['week']))

    {

            
    //$modalityselected=global_modality;
            //echo"--------".$modalityselected;
            
    $week $_GET['week'];
            
    //$modalityid=$_POST[selectedid];
            //echo"----------------".$modalityid;
        
    echo '<table id="reservation_table"><colgroup span="1" id="reservation_time_colgroup"></colgroup><colgroup span="7" id="reservation_day_colgroup"></colgroup>';

        
    $days_row '<tr><td id="reservation_corner_td"><input type="button" class="blue_button small_button" id="reservation_today_button" value="Today"></td><th class="reservation_day_th">Monday</th><th class="reservation_day_th">Tuesday</th><th class="reservation_day_th">Wednesday</th><th class="reservation_day_th">Thursday</th><th class="reservation_day_th">Friday</th><th class="reservation_day_th">Saturday</th><th class="reservation_day_th">Sunday</th></tr>';

        if(
    $week == global_week_number)
        {
            echo 
    highlight_day($days_row);
        }
        else
        {
            echo 
    $days_row;
        }

        foreach(
    $global_times as $time)
        {
            echo 
    '<tr><th class="reservation_time_th">' $time '</th>';

            
    $i 0;

            while(
    $i 7)
            {
                
    $i++;
                
                echo 
    '<td><div class="reservation_time_div"><div class="reservation_time_cell_div" id="div:' $week ':' $i ':' $time '" onclick="void(0)">' read_reservation($week$i$time). '</div></div></td>';
            }

            echo 
    '</tr>';
        }

        echo 
    '</table>';
    }
    else
    {
        echo 
    '</div><div class="box_div" id="reservation_div"><div class="box_top_div" id="reservation_top_div"><div id="reservation_top_left_div"><a href="." id="previous_week_a">&lt; Previous week</a></div><div id="reservation_top_center_div">Reservations for week <span id="week_number_span">' global_week_number '</span></div><div id="reservation_top_right_div"><a href="." id="next_week_a">Next week &gt;</a></div></div><div class="box_body_div"><div id="reservation_table_div"></div></div></div><div id="reservation_details_div">';
    }

    ?>
    please help me this problem will mad me , I couldn't solve it
    Regards
    Mostafa
    Last edited by spikeZ; Mar 2, 2014 at 12:10.

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    change
    PHP Code:

    echo '<pre>'
      
    print_r($_POST['opts']);
      echo 
    '</pre>'
    tp
    PHP Code:
    echo '<pre>'
      
    print_r($_POST);
      echo 
    '</pre>'
    and the problem should become clear
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •