bettyatolive Posted June 21, 2006 Share Posted June 21, 2006 I have some hidden values.. How do i retrieve those hidden values? Like I have code :[code]<input type=hidden name=rc value=<?=$rcid;?> [/code]Now how do i get that 'rc' value??? Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/ Share on other sites More sharing options...
benji87 Posted June 21, 2006 Share Posted June 21, 2006 Well that depends on how you are using the hidden field. Are you using the hidden field in a form to post?If so its quite simple[code]<?$hiddenvalue = $_POST['rc'];echo '$hiddenvalue';?>[/code]Also take the '=' out of your php hidden value Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47947 Share on other sites More sharing options...
ToonMariner Posted June 21, 2006 Share Posted June 21, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47949 Share on other sites More sharing options...
bettyatolive Posted June 21, 2006 Author Share Posted June 21, 2006 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 Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47965 Share on other sites More sharing options...
benji87 Posted June 21, 2006 Share Posted June 21, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47972 Share on other sites More sharing options...
AndyB Posted June 21, 2006 Share Posted June 21, 2006 [!--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? Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47974 Share on other sites More sharing options...
bettyatolive Posted June 21, 2006 Author Share Posted June 21, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47980 Share on other sites More sharing options...
benji87 Posted June 21, 2006 Share Posted June 21, 2006 So your wanting to autofil a field with values from a database based on what the user selects in the previous box? i.e North or South?? Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47984 Share on other sites More sharing options...
bettyatolive Posted June 21, 2006 Author Share Posted June 21, 2006 Ya, tht's wht i exactly want. Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-47985 Share on other sites More sharing options...
benji87 Posted June 21, 2006 Share Posted June 21, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-48006 Share on other sites More sharing options...
bettyatolive Posted June 21, 2006 Author Share Posted June 21, 2006 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... Quote Link to comment https://forums.phpfreaks.com/topic/12521-getting-hidden-values/#findComment-48011 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.