Jump to content

Recommended Posts

The same way you get teh values of other form elements. The variable rc will be passed in the $_POST or $_GET array depending on which method you use to submit the form.

If you are trying to retrieve it in that manner now and not getting anything try replacing <?=$rcid;?> with <?php echo $rcid; ?> I know its longer but I hate shorthand php ;)

If that is still failing make sure rcid is set - you can do that quickly by changing type from hidden to text and see if it has an initial value.
Link to comment
https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47949
Share on other sites

The $_post function willonly work if you place it in the file that is you're form action.

Here is a basic example:

form.php

[code]
<form name="form1" method="post" action="showname.php">
<input name="firstname" type="text" id="firstname">
<input name="lastname" type="text" id="lastname">
<input name="rc" type="hidden" id="rc" value="<? echo '$rcid' ?>">
<input type="submit" name="Submit" value="Submit">
</form>
[/code]

showname.php
[code]
<?php
$firstname = $_post['firstname'];
$lastname = $_post['lastname'];
$rcid = $_post['rc'];

echo '$firstname, $lastname';
echo ' the hidden value in the form is $rcid';
?>[/code]

That is the basic way but it all depends where your getting the $rcid from. Are u getting it from a database?

Link to comment
https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47972
Share on other sites

[!--quoteo(post=386326:date=Jun 21 2006, 06:43 AM:name=Betty)--][div class=\'quotetop\']QUOTE(Betty @ Jun 21 2006, 06:43 AM) [snapback]386326[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I need to use that value in the same form..... And when i'm using $_POST['rc'] it's not giving me the value
[/quote]

Where does the value come from? Is it declared as a variable in 'this' script? Is it created in another script and passed to this script in a form or via a link?
Link to comment
https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47974
Share on other sites

Actually i have two text boxes region and type. I have to select a value from region( Whose values r in database) and based on tht value the type has to change.
For eg: If there are 2 regions North n South . And each region has it's own types. These values are stored in the database.
When I select region as north in the first listbox I should have the values "123" and "456".
When i select region as South in the first list box then it should be giving me drop down as "xyz","pqr".
These "123,"456","xyz","pqr" are stored in the database with their own region id's.
Link to comment
https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47980
Share on other sites

Then you dont use sql for that you use javascript like so:

[code]
<script language="Javascript">

function autofillin(frm)
{
     if("North" == frm.region.value)
     {
          frm.type.value = "123";
          frm.type.value = "456";
     }
     if("South" == frm.region.value)
     {
          frm.type.value = "abc";
          frm.type.value = "def";
     }
    
}

</script>
<body>
<form name="frm" method="post" action="">
<td>Region</td>
<td><select onchange="autofillin(this.form)" name="region">
<option value="North">North</option>
<option value="South">South</option>
</select>
<td>Type</td>
<td><select name="type" id="type">
</select>
</form>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-48006
Share on other sites

benji87,
I have to use the database b'coz there is a stand alone application and the client should be able to change the value types of a particular region i.e. add / delete "123","456".

Can you please give me other solution please... ??
U caN still use Javascript but only with the database...
Link to comment
https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-48011
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.