is it possible to have Postback method on page Refresh.??
(Hold the values of a form on page refresh..!!)

I have Two Columns for Example:

Items | Price
item1 | textbox(in which we fill price)
item2 | textbox(in which we fill price)
item3 | textbox(in which we fill price)
Add new Item Button

When i click on Add new Item Button a new popup will open in which i add new Item and on close,it will refresh the Parent Page..So that new Item can be display in the list..!!

but this vanish the value of price textbox which we fill before adding new Item..!!! :(

hmmmm i hope u guys have solution..!! :)
help me out..!!

Ya just depends on your programming style.
Sessions would be an acceptable 'post_back' method.

hi

As per my view you can use hidden field in html which hold your price list and you can get this value by the $_post right.

Thanks

Ya just depends on your programming style.
Sessions would be an acceptable 'post_back' method.

Well i know to store the value of textbox in session after submit the form..!!!
but how can you store the value in session on Popup window..??? :O

hi

As per my view you can use hidden field in html which hold your price list and you can get this value by the $_post right.

Thanks

How can we use $_post on page Refresh.?? [:O]

Popup window you mean target="_blank"?
You would use the same $_SESSION variables wouldnt matter.
Make sure you always start a session and you do not need to submit a form to have sessions working.
Maybe do abit of research into sessions so you understand them better.

Let me know how you go.

Popup window you mean target="_blank"?
You would use the same $_SESSION variables wouldnt matter.
Make sure you always start a session and you do not need to submit a form to have sessions working.
Maybe do abit of research into sessions so you understand them better.

Let me know how you go.

Sir,
Thnks for the reply..
Yes, with popup window i mean new window with target="_blank"..
you are right i need to research more on sessions..!!
but sir can tell me, how can i store a value of textbox in session without submiting or without sending values to another page to store that value in session...??? :O

tht will be a gr8 help.. :)

Thnk u..!!

Oh that is easy. Does that solve your problem?

<input type="textbox" value="<?php echo $_SESSION['abc']; ?>" />

Oh that is easy. Does that solve your problem?

<input type="textbox" value="<?php echo $_SESSION['abc']; ?>" />

Sir i thnk before 'echo' the session.. we have to store it in Session..!!! like $_SESSION = $_POST;

Oh that is easy. Does that solve your problem?

<input type="textbox" value="<?php echo $_SESSION['abc']; ?>" />

Sir i thnk before 'echo' the session.. we have to store it in Session..!!!
lets take an example:
<input type="textbox" name="abc" value="<?echo $_SESSION ?>">

Now user input the value in Textbox is 2...!!!!

Now the i want to store value "2" in session.. the only method i know to store value in session is sending the value on same page or another page..!!

$_SESSION = $_POST;

Now value '2' is store in SESSION....

Do u know any method to store value'2' in session without sending it to anywhere..????? :O

I cant explain to you everything about sessions but I can give you an example, that will hopefully solve your problem.

// PAGE 1
session_start();
$_SESSION['abc'] = "2";

// PAGE 2
session_start();
echo $_SESSION['abc];

Understand the logic behind it now?

Let me know how you go.

I cant explain to you everything about sessions but I can give you an example, that will hopefully solve your problem.

// PAGE 1
session_start();
$_SESSION['abc'] = "2";

// PAGE 2
session_start();
echo $_SESSION['abc];

Understand the logic behind it now?

Let me know how you go.

yes sir i understand the code but sir value '2' is dynamic not static..!!! value can be 2,3,4 etc whatever user can input in it..!!!!

in my example you clearly see, i take '2' as userinput not static input..!!!

//now page1
session_start();
$_SESSION = ??? // how will you collect value of userinput
without sending it anywhere..!!

<input type='text' value="echo $_SESSION " name="abc">

<!-- you dont know what user going to input.. -->

I hope now you get what exactly i want..!!! :)

is it possible to have Postback method on page Refresh.??
(Hold the values of a form on page refresh..!!)

You want to preserve the data or state of form input tag even after the page is posted back.

State management : home-made measures needed to preserve the state. Traditionally, statlessness hav been overcome with use of cookies, session, hidden fields, sticky form, and query string.

Here is an example code for everything to solves your questions:

// Page 1
session_start(); // Starts the session
<input type="textbox" name="textbox_name" /> // User enters 123
$_SESSION['textbox_session'] = $_POST['textbox_name'];

// Page 2
session_start(); // Starts the session
echo $_SESSION['textbox_session'];

You understand the logic? If not do some research?

adatapost>Example code is not a solution after all. If a person is not able to program himself/herself then he/she must introspect.

The logic behind the code answers all his questions.
If he has further questions he just needs to ask.
adatapost > If you have nothing positive to add best not post than to be thought an idiot.

Here is an example code for everything to solves your questions:

// Page 1
session_start(); // Starts the session
<input type="textbox" name="textbox_name" /> // User enters 123
$_SESSION['textbox_session'] = $_POST['textbox_name'];

// Page 2
session_start(); // Starts the session
echo $_SESSION['textbox_session'];

You understand the logic? If not do some research?

Sorry sir but i dont understand that why you use $_POST when you not sending any data anywhere...
I hope you know that :
The built-in $_POST function is used to collect values from a form sent with method="post".

But we are here not sending data anywhere so it is useless to use $_POST..!!! thats what i m saying from very starting..!! I have to Hold data on page refresh(without using submit or without using any event)..!!!!
Sir this time you need to research little bit..!!!

Thanks for your Kind Patience..:)

How can you not be sending data?
The layout of your example, you would presumme it would be sending data.
If you not going to use 'post' use another 'session'.

List your code im getting tired of trying to guess what it is :|

How can you not be sending data?
The layout of your example, you would presumme it would be sending data.
If you not going to use 'post' use another 'session'.

List your code im getting tired of trying to guess what it is :|

Respected Sir i dont thnk my very first post was difficult to understand..!!! Now i try my best to made it more clear....!!!

<form action="add.php" method="post">
<table>
    <tr>
         <td>Items</td> 
         <td>Price</td>
  </tr>
   <tr>
     <? while($row=mysql_fetch_array($result)) { ?>
      {
      <td><?= $row['Item'];  ?> </td> //this will fetch Item from DB..
      <td><input type="text" name="price"></td> 
                                         // in this text box   user  input the price..!!
<?}?>
<button  type="button" onclick="return myPopup2();"><span>Add New Item</span></button></td> 

// This Add New Item Button will open a popup window through which I can add new Item... and on close of pop-up window the parent page will REFRESH... So that the NEW ITEM can be Displayed in the List..!!!

Note : Add Button is not a Submit button.. it jst call a Javascript Function to open a Window..!!

Now i want to Hold the Value of Price TextBox which user input in it at time page refresh..!!

Suppose User got the page with 5 items...!!!

ITEMS | PRICE
ITEMS1 | 50 // Items are coming from db and User input the Price
ITEMS2 | 30
ITEMS3 | 20
ITEMS4 | 40
ITEMS5 | 60
ADD New ITEM (Button) // After Filling the Prices of First 5 Items,User Feels that He forgot to add ITEM 6 then he will Click on Add Item Button,a Popup Window Will Open through Which User Add Item 6 and on Close of that window... the Parent page will Refresh and Item 6 will displayed in the list..!!! But the values which User filled in Price textbox will be vanished...!!!

and I want to hold that Price Value on page refresh...!!!! :(

Now i hope clear Idea whta i want...?? :)
I hope You reply with a Good Solution..!!

Thnk You Sir.!!! :)

Ok thats better now I understand your situation abit better.

But still you get the same answer, you have tried $_SESSION and $_POST ? Im sure either one would work if $_POST does not work cause technically there has been no information sent then sessions should work. popup2() is a function that opens a new php page I gather? So you should be able to declare either $_SESSION or $_POST within the value parameters of those text boxes.

In short have you tried $_POST or $_SESSION?
or you do not know how to implement either?

Ok thats better now I understand your situation abit better.

But still you get the same answer, you have tried $_SESSION and $_POST ? Im sure either one would work if $_POST does not work cause technically there has been no information sent then sessions should work. popup2() is a function that opens a new php page I gather? So you should be able to declare either $_SESSION or $_POST within the value parameters of those text boxes.

In short have you tried $_POST or $_SESSION?
or you do not know how to implement either?

Sir i m glad that my last attempt made u clear the situation..!! :)

yes technically i cant use the $_POST as i m sending any data..!!!
Now how can i use $_SESSION..?? as i have to store the value of textbox first in session for that in need $_POST but unfortunately i cant use $_POST..!!!
:(

can you guide or write little code how can i pass perameter through popup window or how to store value in session without using $_POST..?? :)

hi,
without posting the page you can not get the textbox value after the page refresh
so here is the code where you submit the page when you open the popup window ok

document.employer_register.action="employer_save.php";
	document.employer_register.submit();

above is the example code
where user click on add new text box button then you can call the javascript function and submit the form so now you can able to store textbox value in session

Thanks

Here is an example code for everything to solves your questions:

// Page 1
session_start(); // Starts the session
<input type="textbox" name="textbox_name" /> // User enters 123
$_SESSION['textbox_session'] = $_POST['textbox_name'];

// Page 2
session_start(); // Starts the session
echo $_SESSION['textbox_session'];

You understand the logic? If not do some research?

I already gave you sample code!!!
What dont you understand of this?

I was thinking about how I could further help you...

How about you try some session coding and I will debug it for you and once you have done that you would have obtained the knowledge to solve this thread? or even questions about the logic behind sessions?

I was thinking about how I could further help you...

How about you try some session coding and I will debug it for you and once you have done that you would have obtained the knowledge to solve this thread? or even questions about the logic behind sessions?

here is my full page code...

<?include_once('session.php');?>       
<html dir="ltr"><head>
<title>Items List</title>
<link href="default.css" rel="stylesheet" type="text/css"> 
<script type="text/javascript" src="time.js"></script>
<script src="currentdate.js"></script>
<script type="text/javascript" src="popup.js"></script>   
<?php
    include_once('config.php');
    $userid = $_SESSION['userid'];
    $sql="SELECT * FROM items where user_id = $userid or user_id = 0";
    $result=mysql_query($sql) or die('Query error:'.''.mysql_error());   
?>
</head>
<body onload="startTime(); currentdate();">
<?php include_once('header.php');  
    include_once('menu4.php');?>
<div class="clear">
</div>
<center>
 <table border="0" width="100%">
    <tr>
        <td width="20%"><font face="Courier New, Courier, mono" size="+1"><b>View Item</b></font></td>
        <td align="center" width="50%"><b> Welcome&nbsp;&nbsp;<?= $_SESSION['username'];?></b></td>
        <td align="right"><div id="txt1"></div></td>    
    </tr>
    <tr>
        <td class="titletext" style="">&nbsp;</td>
        <td align="right" class="titletext" colspan="2">Time:<span id="txt"></span></td>
    </tr>
</table>
<div class="clear"></div>
<center><table width="100%"><tbody><tr>
<div id="_page_body">
<br> <? include_once('error.php'); ?>       <br>
<form method="post" name="frm" action="addbudget.php" onSubmit="return formValidate(this);">
        
        <input type="hidden" id='userid' name="userid" value="<?= $userid; ?>"
        <div><center> 
        <table style="border-collapse: collapse;" cellpadding="3" cellspacing="3" align="center" border="1"  bgcolor="#f9f9f9" border="2" bordercolor="#e1e1e1">
    <tr>
        <td class="tableheader">Select Month</td>
        <td class="tableheader">Select Year</td>
    </tr>
    <tr>
        <td align="center">
           <select name="month" id="month" style="width:100px">
            <option value="1" <? if( $_SESSION['month'] == "1") echo 'selected';?>>January</option>
            <option value="2" <? if( $_SESSION['month'] == "2") echo 'selected';?>>Febuary</option>
            <option value="3" <? if( $_SESSION['month'] == "3") echo 'selected';?>>March</option>
            <option value="4" <? if( $_SESSION['month'] == "4") echo 'selected';?>>April</option>
            <option value="5" <? if( $_SESSION['month'] == "5") echo 'selected';?>>May</option>
            <option value="6" <? if( $_SESSION['month'] == "6") echo 'selected';?>>June</option>
            <option value="7" <? if( $_SESSION['month'] == "7") echo 'selected';?>>July</option>
            <option value="8" <? if( $_SESSION['month'] == "8") echo 'selected';?>>Augest</option>
            <option value="9" <? if( $_SESSION['month'] == "9") echo 'selected';?>>September</option>
            <option value="10" <? if( $_SESSION['month'] == "10") echo 'selected';?>>Octuber</option>
            <option value="11" <? if( $_SESSION['month'] == "11") echo 'selected';?>>November</option>
            <option value="12" <? if( $_SESSION['month'] == "12") echo 'selected';?>>December</option>
        </select>
         <td>  
            <select name="year" style="width:100px">
            <?
            $year = date(Y);
            for($i=1;$i<=5;$i++)
            {?>
                
              <option value="<?= $year;?>"><?= $year ?></option>  
              <?$year = $year + 1;?>
           <? }?>
            </select>
         </td>   
   </tr>
</table>
<br>
<table style="border-collapse: collapse;" bgcolor="#f9f9f9" border="2" bordercolor="#e1e1e1" cellpadding="3" cellspacing="3" width="80%">
    <tr>
        <td class="tableheader">Select</td>
        <td class="tableheader">Item Name</td>
        <td class="tableheader">Price</td>
    </tr>
      <? 
              $className = "evenrow";
              $count=0;
              while($row= mysql_fetch_array($result)) { 
      ?>
      
    <tr class="<?= $className ;?>"> 
        <td align="center"><input type="checkbox" name="chk<?=$count;?>"  id="chk<?=$count;?>" onClick="disable(this);able(this);" value="<?=$count;?>" <?if(isset($_SESSION['bamt'.$count])) echo 'checked'; ?>></td>
        <td align="center"><?= $row['ledgerName'];?><input type="hidden" id='ledger<?=$count?>' name='ledger<?=$count?>' value="<?=$row['ledger_id'];?>"></td>
        <td align="center"><input maxlength="8" type="text" value="<?= $_SESSION['bamt'.$count]?>" name="bamt<?=$count;?>" id="bamt<?=$count; ?>" class="textbox2" <?if(isset($_SESSION['bamt'.$count])) echo'enabled'; else echo 'disabled'; ?>></td>
       
        
        <? $count++; 
            if($className == 'evenrow')
            {
                $className = oddrow;
            }
            else
            {
                $className = evenrow;
            }
        }
    ?>
    <tr>
        <td colspan="5" align="center"><button  type="button" onclick="return myPopup2();"><span>Add New Ledger</span></button></td>
        </tr>    
</tbody>
</table>
<br>
<button class="ajaxsubmit" type="submit" name="Process" id="Process" onclick="return countCheckboxes();"><span>Submit</span></button>
</center>
</center>
<input type="hidden" name="counter" value="<?=$count?>">
<input type="hidden" name="check" id='check'>
</form>
<br><div id="footer"> 
<?php include_once('footer.html');  
for($i=0;$i<=$count;$i++)
{
    if(isset($_SESSION['bamt'.$i]))
        {          
            unset($_SESSION['bamt'.$i]);
        }  
}
?>
</body>
</html>

kindly tell what can i do...??
And Thnx for your Support

Can you put it blocks so I can see it clearly.

Also is the ajaxbutton the one that popsup the php window?[code=php] blocks so I can see it clearly.

Also is the ajaxbutton the one that popsup the php window?

Can you put it (code) blocks so I can see it clearly.

Also is the ajaxbutton the one that popsup the php window?

<?include_once('session.php');?>       
<html dir="ltr"><head>
<title>Items List</title>
<link href="default.css" rel="stylesheet" type="text/css"> 
<script type="text/javascript" src="time.js"></script>
<script src="currentdate.js"></script>
<script type="text/javascript" src="popup.js"></script>   
<?php
    include_once('config.php');
    $userid = $_SESSION['userid'];
    $sql="SELECT * FROM items where user_id = $userid or user_id = 0";
    $result=mysql_query($sql) or die('Query error:'.''.mysql_error());   
?>
</head>
<body onload="startTime(); currentdate();">
<?php include_once('header.php');  
    include_once('menu4.php');?>
<div class="clear">
</div>
<center>
 <table border="0" width="100%">
    <tr>
        <td width="20%"><font face="Courier New, Courier, mono" size="+1"><b>View Item</b></font></td>
        <td align="center" width="50%"><b> Welcome&nbsp;&nbsp;<?= $_SESSION['username'];?></b></td>
        <td align="right"><div id="txt1"></div></td>    
    </tr>
    <tr>
        <td class="titletext" style="">&nbsp;</td>
        <td align="right" class="titletext" colspan="2">Time:<span id="txt"></span></td>
    </tr>
</table>
<div class="clear"></div>
<center><table width="100%"><tbody><tr>
<div id="_page_body">
<br> <? include_once('error.php'); ?>       <br>
<form method="post" name="frm" action="addbudget.php" onSubmit="return formValidate(this);">

        <input type="hidden" id='userid' name="userid" value="<?= $userid; ?>"
        <div><center> 
        <table style="border-collapse: collapse;" cellpadding="3" cellspacing="3" align="center" border="1"  bgcolor="#f9f9f9" border="2" bordercolor="#e1e1e1">
    <tr>
        <td class="tableheader">Select Month</td>
        <td class="tableheader">Select Year</td>
    </tr>
    <tr>
        <td align="center">
           <select name="month" id="month" style="width:100px">
            <option value="1" <? if( $_SESSION['month'] == "1") echo   'selected';?>>January</option>
            <option value="2" <? if( $_SESSION['month'] == "2") echo 'selected';?>>Febuary</option>
            <option value="3" <? if( $_SESSION['month'] == "3") echo 'selected';?>>March</option>
            <option value="4" <? if( $_SESSION['month'] == "4") echo 'selected';?>>April</option>
            <option value="5" <? if( $_SESSION['month'] == "5") echo 'selected';?>>May</option>
            <option value="6" <? if( $_SESSION['month'] == "6") echo 'selected';?>>June</option>
            <option value="7" <? if( $_SESSION['month'] == "7") echo 'selected';?>>July</option>
            <option value="8" <? if( $_SESSION['month'] == "8") echo 'selected';?>>Augest</option>
            <option value="9" <? if( $_SESSION['month'] == "9") echo 'selected';?>>September</option>
            <option value="10" <? if( $_SESSION['month'] == "10") echo 'selected';?>>Octuber</option>
            <option value="11" <? if( $_SESSION['month'] == "11") echo 'selected';?>>November</option>
            <option value="12" <? if( $_SESSION['month'] == "12") echo 'selected';?>>December</option>
        </select>
         <td>  
            <select name="year" style="width:100px">
            <?
            $year = date(Y);
            for($i=1;$i<=5;$i++)
            {?>

              <option value="<?= $year;?>"><?= $year ?></option>  
              <?$year = $year + 1;?>
           <? }?>
            </select>
         </td>   
   </tr>
</table>
<br>
<table style="border-collapse: collapse;" bgcolor="#f9f9f9" border="2" bordercolor="#e1e1e1" cellpadding="3" cellspacing="3" width="80%">
    <tr>
        <td class="tableheader">Select</td>
        <td class="tableheader">Item Name</td>
        <td class="tableheader">Price</td>
    </tr>
      <? 
              $className = "evenrow";
              $count=0;
              while($row= mysql_fetch_array($result)) { 
      ?>

    <tr class="<?= $className ;?>"> 
        <td align="center"><input type="checkbox" name="chk<?=$count;?>"  id="chk<?=$count;?>" onClick="disable(this);able(this);" value="<?=$count;?>" <?if(isset($_SESSION['bamt'.$count])) echo 'checked'; ?>></td>
        <td align="center"><?= $row['ledgerName'];?><input type="hidden" id='ledger<?=$count?>' name='ledger<?=$count?>' value="<?=$row['ledger_id'];?>"></td>
        <td align="center"><input maxlength="8" type="text" value="<?= $_SESSION['bamt'.$count]?>" name="bamt<?=$count;?>" id="bamt<?=$count; ?>" class="textbox2" <?if(isset($_SESSION['bamt'.$count])) echo'enabled'; else echo 'disabled'; ?>></td>


        <? $count++; 
            if($className == 'evenrow')
            {
                $className = 'oddrow';
            }
            else
            {
                $className = 'evenrow';
            }
        }
    ?>
    <tr>
        <td colspan="5" align="center"><button  type="button" onclick="return myPopup2();"><span>Add New Ledger</span></button></td>
        </tr>    
</tbody>
</table>
<br>
<button class="ajaxsubmit" type="submit" name="Process" id="Process" onclick="return countCheckboxes();"><span>Submit</span></button>
</center>
</center>
<input type="hidden" name="counter" value="<?=$count?>">
<input type="hidden" name="check" id='check'>
</form>
<br><div id="footer"> 
<?php include_once('footer.html');  
for($i=0;$i<=$count;$i++)
{
    if(isset($_SESSION['bamt'.$i]))
        {          
            unset($_SESSION['bamt'.$i]);
        }  
}
?>
</body>
</html>

ajaxbutton is jst css class.. there is javascript function myPopup2 through which Popup Window open..!! You can see that i call that function on onClick...!!

Edited 3 Years Ago by mike_2000_17: Fixed formatting

After looking at your code in detail there is no process in place ot save the data posted, like you wished.

Now there are various things you could do to solve this solution but a quick and easy solution without recoding the whole page would be a save button imo.
So this how it would work.
- User types in A = 100, B = 200, C= 300.
- Then user would click SAVE BUTTON
-- This button would be a submit button within a form and would send the $_POST values to itself and reload with the posted values.

<form action="<?php $_SERVER['php_self'] ?>" method="post">
 <input type="text" name="text_a" value="<?php echo $_POST['text_a'] ?>" />
 <input type="submit" value="SAVE" />
</form>

Do you understand now? Implement this example onto your project.

After looking at your code in detail there is no process in place ot save the data posted, like you wished.

Now there are various things you could do to solve this solution but a quick and easy solution without recoding the whole page would be a save button imo.
So this how it would work.
- User types in A = 100, B = 200, C= 300.
- Then user would click SAVE BUTTON
-- This button would be a submit button within a form and would send the $_POST values to itself and reload with the posted values.

<form action="<?php $_SERVER['php_self'] ?>" method="post">
 <input type="text" name="text_a" value="<?php echo $_POST['text_a'] ?>" />
 <input type="submit" value="SAVE" />
</form>

Do you understand now? Implement this example onto your project.

Sir
Sorry for late reply i was out of town..!! I m glad finally i make you understand a simple Query..!!! :D

I hope,now u understand without submit you cant store value in session in my case..!!! :D

Well I m thankful for your patience..
i have solved the query with Javascript...!!!

THREAD SLOVED..!!! :))

This article has been dead for over six months. Start a new discussion instead.