PostBack method on Page Refresh
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..!!
nish123
Junior Poster in Training
83 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
Ya just depends on your programming style.
Sessions would be an acceptable 'post_back' method.
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
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['hidden_fiels'] right.
Thanks
Tulsa
Junior Poster in Training
77 posts since May 2009
Reputation Points: 13
Solved Threads: 15
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
nish123
Junior Poster in Training
83 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
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['hidden_fiels'] right.
Thanks
How can we use $_post['hidden_fiels'] on page Refresh.?? [:O]
nish123
Junior Poster in Training
83 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
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.
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
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..!!
nish123
Junior Poster in Training
83 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
Oh that is easy. Does that solve your problem?
<input type="textbox" value="<?php echo $_SESSION['abc']; ?>" />
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
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['abc'] = $_POST['abc'];
nish123
Junior Poster in Training
83 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
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:
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['abc'] = $_POST['abc'];
Now value '2' is store in SESSION....
Do u know any method to store value'2' in session without sending it to anywhere..????? :O
nish123
Junior Poster in Training
83 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
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.
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
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['abc'] = ??? // how will you collect value of userinput
without sending it anywhere..!!
I hope now you get what exactly i want..!!! :)
nish123
Junior Poster in Training
83 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
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.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
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?
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
adatapost>Example code is not a solution after all. If a person is not able to program himself/herself then he/she must introspect.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
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.
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
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..:)
nish123
Junior Poster in Training
83 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
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 :|
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
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.!!! :)
nish123
Junior Poster in Training
83 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
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?
OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10