PDA

View Full Version : Set a variable from a form text field


Richard Diedrick
09-21-2010, 08:32 PM
I need to understand how to set a variable from the value that is in a text field on a form. The form is populated by a recordset and I need the variable to change if the form is advanced to the next record or to the previous record.
I have tried
$prospect_id=$_POST['hiddenField'];
$prospect_id = $_SESSION['MM_Prospect_ID']

but either the code is not correct or I do not know where to put it.

edbr
09-22-2010, 01:15 AM
not clear what you want $prospect_id=$_POST['hiddenField']; returns the field in your form presumably fed form the data base, but what are you trying to do with the second?

Richard Diedrick
09-22-2010, 02:17 AM
I am not sure at all about the code I put in the post. What I need to do is get the value from a text field that is in a form. The form gets it's values from a recordset attached to the php web page. I then need to use the variable in two ways.
1. To use in a select query that is attached to the same php web page and is used to populate an accordian spry widget.
2. I need to assign the variable's value to a session variable to be used on additional pages.
The code in the post was just an attempt by someone who is unsure how the this should be done, me!! Thanks for any help.

edbr
09-22-2010, 02:56 AM
so the first part as ia said returns the db value
$prospect_id=$_POST['hiddenField'];

$_SESSION['prospect'] =$prospect_id; creates a session value of the value
which can be returned
\I need the variable to change if the form is advanced to the next record or to the previous record.
you have to be more specific what does change if the selection is changed?if the form is posted again it should replace the session value

Richard Diedrick
09-22-2010, 05:50 AM
I need the variable to change if and when the text value in the form changes, such as going to a different record in the recordset. Using the code in my post I get errors. I think it is based on where the code is placed? Also does post only work after the form is submitted? I need the value to be the current value so the other recordset reflects the appropriate value.

Richard Diedrick
09-22-2010, 05:59 AM
I am attaching a text file of the php page I am working with. I will understand if it represents to much of your time to look at it but it seems the best way to try and explain what I am trying to do. You will see 2 recordsets attached to the form. I need the sic_code recordset to use the sic_code value of the prospects recordset to get the corresponding record. Hope that makes sense.

Richard Diedrick
09-25-2010, 03:37 AM
I guess there is no interest in replyng further?

edbr
09-25-2010, 04:32 AM
im confused as to what you are trying to do frankly.

Richard Diedrick
09-25-2010, 07:12 AM
I am trying to set a varable's value from the content of a text field that is part of a form. The form gets its data from a recordset. I will use the value of the variable to set the content of a second recordset. I need the value of the variable to change when the value of the text field changes. That's it.

edbr
09-27-2010, 01:18 AM
how do you change the value? basically though you should be able to re-defne the variable after the change further down in the script

Richard Diedrick
09-29-2010, 04:44 AM
figured it out $sic_code=$row_prospects['Sic Code']; after first recordset & before second using $sic_code to create 2nd recordset

Richard Diedrick
11-01-2010, 11:49 PM
Turns out this was actually pretty simple to accomplish using the recordset value as opposed to the value of the text field
$sic_code_used=$row_prospects['sic_code'];
still need to figure out how to set a variable from the value in a text field which apperently either is not done or not done here