i am trying to print the value of $ss. but it say 'qty' is undifine on line($ss = $_post['qty'];).

index.php

<?php
echo"
<form  method='post' action='index.php'>

   <input type='text'  name='qty' />

    <button type='submit' id='opener01'  name='b1'>submit</button>

</form>";



echo"
<div id='dialog01' title='ccc'> ";
                $ss = $_post['qty'];
                echo"$s;

    echo"
    </div>";
?>

jquery.js

$( "#dialog01" ).dialog({
    autoOpen: false, 
    modal: true,
    buttons: {
        "option1": function() {
            $( this ).dialog( "close" );
         },
        "exit": function() {
            $( this ).dialog( "close" );
        }
    }
});
$( "#opener01" ).click(function() {
      $( "#dialog01" ).dialog( "open" );
      return false;
}); 

$_post is incorrect as always needs to be in upper case so change to $_POST

This code can not display the value of $ss, because you are echoing $s instead. Please rectify that first.

Hi Webville, I think you mistook the second 's' character as a dollar sign.

Hi Hwoarang,
Simplypixie was right, you should make the $_post all-caps. Change it to $_POST

ERRATA:
Hi Webville, you were right. LOL
Hoarang, you are also echoing the wrong variable. See line 15 and 16 of your sample.

ops sorry i made a mistake when i was type it on daniweb.com.

on my code i have POST caps and echo"$s" is echo"$ss"

In which case your echo statement is incorrect, try

$ss = $_POST['qty'];
echo "<div id='dialog01' title='ccc'>".$ss."</div>";

Please mark this as Solved if fixed.

Member Avatar for diafol
echo "<div id='dialog01' title='ccc'> ";
$ss = $_post['qty'];
echo "$ss;  //WHY THE " ? No need 
echo "</div>";

Also on page load, you'll get an error as the $_POST['qty'] won't exist yet as you've not submitted the form. Use and 'if':

if(isset($_POST['qty'])){
    $ss = $_POST['qty']; //escape or validate as required
    echo "<div id='dialog1 title='cc'>$ss</div>";
}

Or looking at your ajax - you probably need the div to be present on page load:

$ss = (isset($_POST['qty']) ? $_POST['qty'] : 0;
echo "<div id='dialog1 title='cc'>$ss</div>";

ahh i c the problem. in order for $ss has a value, the page need to refesh/submit. and bc iam using ajax to open dialog box thats why $ss has no value yet.

is there a way for me to send value in div dialog box?

//dialog box - prints "no post"

echo"
<div id='dialog01' title='ccc'> ";
       if(isset($_POST['qty'])){        
               $ss = $_post['qty'];
                echo $ss;
                }
                else
                {
                echo"NO POST";
               }

    echo"
    </div>";
Member Avatar for diafol

Your code should be OK for setting an initial value to the dialog. Is it solved?

nope not solved. let me repost all the code i have so far

inside div dialog01 i want to echo $ss. but its echo out "no POST". i am not sure how can i echo the value of qty.

index.php

    <?php
    echo"
    <form  method='POST' action='index.php'>

       <input type='text'  name='qty' />

        <button type='submit' id='opener01'  name='b1'>submit</button>

    </form>";

 echo"
<div id='dialog01' title='ccc'> ";
       if(isset($_POST['qty'])){        
               $ss = $_post['qty'];
                echo $ss;
                }
                else
                {
                echo"NO POST";
               }

    echo"
    </div>";
    ?>

jquery.php

$( "#dialog01" ).dialog({
    autoOpen: false, 
    modal: true,
    buttons: {
        "option1": function() {
            $( this ).dialog( "close" );
         },
        "exit": function() {
            $( this ).dialog( "close" );
        }
    }
});
$( "#opener01" ).click(function() {
      $( "#dialog01" ).dialog( "open" );
      return false;
}); 
Member Avatar for diafol

Change this:

$ss = $_post['qty'];

to this:

$ss = $_POST['qty'];

Simplypixie and gon1387 mentioned this.

my bad i have it cap on my computer. i just keep forgeting it on daniweb.

Member Avatar for diafol

So, does it work now?

no

inside div dialog01 i want to echo $ss. but its echo out "no POST". i am not sure how can i echo the value of qty.

Member Avatar for diafol
$( "#opener01" ).click(function() {
      $( "#dialog01" ).dialog( "open" );
      return false;
}); 

Is this preventing form submission? If so, you won't get a $_POST['qty'] as the page is not refreshing and you don't have any ajax to provide a post method. So, why not forget the post and take the value directly from the form via js:

$( "#opener01" ).click(function() {
      $( "#dialog01" ).dialog( "open" );
      $( "#d1Container").html($("#qty").val());
      return false;
}); 

BUT have this:

<input type='text' id='qty' name='qty' />

And this:

<div id='dialog01' title='ccc'> ";
    <div id='d1Container'>No Value</div>
</div>";

Not sure if that'll work once the dialog is open, perhaps you'll need to swap to:

      $( "#d1Container").html($("#qty").val());
      $( "#dialog01" ).dialog( "open" );
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.