473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

couldn't get hidden type data after form submission

i have two select boxes in my form named month and year...when i selected these two things, there is a submit button called 'generate invoice'. when i click this, invoice report is generated as a table on the same page and i put customer number and block number in the hidden field in this step.....i have another link called 'payment' in the generated table for each row...when i click that link the form gets once again submitted....but, when i am going to retrieve the hidden field data(customer number and block number) i couldn't get that data...why? my code is here

plz solve this problem...
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. require_once('database_conn.php');
  4. session_start();
  5. if(isset($_SESSION['username']))
  6.  ?>
  7. <html>
  8. <head>
  9. <title>Property Management System</title>
  10. <style>
  11. .edit
  12.   {
  13.      text-decoration:underline;
  14.      cursor:pointer;
  15.      color:blue;
  16.   }
  17. </style>
  18. <script type="text/javascript">
  19. function month_display()
  20. {
  21.   if(document.getElementById('billmonth').value=="nil")
  22.   {
  23.    alert("Please Select Month");
  24.   }
  25.  
  26. }
  27. function year_display()
  28. {
  29.   if(document.getElementById('billyear').value==0)
  30.   {
  31.     alert("Please Select Year");
  32.   }
  33.  }  
  34. function payment()
  35. {
  36.  document.forms[0].submit();
  37. }
  38. function validate()
  39. {
  40.   var error="";
  41.   if(document.getElementById('billmonth').value=="nil")
  42.   {
  43.    error +="Please Select Month\n";
  44.   }
  45.   if(document.getElementById('billyear').value==0)
  46.   {
  47.     error +="Please Select Year\n";
  48.   }
  49.   if(error)
  50.    {
  51.     alert(error);
  52.     return false;
  53.    }
  54.   else
  55.     { 
  56.      return true;
  57.     }
  58. }
  59. </script>
  60. </head>
  61. <body>
  62. <?php
  63. include('adminlogin.php');  
  64. ?>
  65. <form action="bill_index.php" method="post" name="cust" onsubmit="javascript:return validate();">
  66.    <?php
  67.    if (isset($_POST['custno'])) 
  68.     {
  69.      $custno=$_POST['custno'];
  70.       echo $custno;
  71.       }
  72.   else
  73.    {
  74.    ?>
  75.   <table border="0" align="center" cellspacing="1" cellpadding="2" class="bg1">
  76.   <div style="position:absolute;left:600px;top:80px;"><input type="text" name="bill_date" readonly="readonly" id="bill_date" value="<?php echo date("F j, Y");?>" class="textfield" size="10" /></div>
  77.   <tr class="bg2"><td>Rent for the Month :</td><td>
  78.   <select name="billmonth" id="billmonth" class="bg2" onChange="month_display()">
  79.   <option value="nil">--Select--</option>
  80.   <?php
  81.       $mnth=array(1=>"Jan",2=>"Feb",3=>"Mar",
  82. 4=>"Apr",5=>"May",6=>"Jun",
  83. 7=>"Jul",8=>"Aug",9=>"Sep",10=>"Oct",11=>"Nov",12=>"Dec");
  84.    if(isset($_POST['billmonth']))
  85.    {
  86.     foreach($mnth as $k=>$v)
  87.     {
  88.      if($k==$_POST['billmonth'])
  89.      { 
  90.    ?>
  91.    <option value="<?php echo $k;?>" selected="selected"><?php echo $v;?></option>
  92.    <?php
  93.      }
  94.    else
  95.    {
  96.    ?>
  97.    <option value="<?php echo $k;?>"><?php echo $v;?></option>
  98.    <?php
  99.     }//else
  100.    }//for
  101.   }//if
  102.   else
  103.   {
  104.     foreach($mnth as $k=>$v)
  105.     {
  106.    ?>
  107.     <option value="<?php echo $k;?>"><?php echo $v;?></option>
  108.   <?php
  109.     }
  110.   }
  111.     ?> 
  112.    </select></td><td>
  113.    Year<select name="billyear" id="billyear" class="bg2" onchange="year_display()">
  114.    <option value="0">--Select--</option>
  115.    <?php
  116.      $yr=array(2007,2008,2009);
  117.    if(isset($_POST['billyear']))
  118.    {
  119.     for($i=0;$i<count($yr);$i++)
  120.     {
  121.        if($yr[$i]==$_POST['billyear'])
  122.        {
  123.       ?>
  124.         <option value="<?php echo $yr[$i];?>" selected="selected"><?php echo $yr[$i];?></option>
  125.       <?php
  126.        }
  127.       else
  128.        {
  129.        ?>
  130.             <option value="<?php echo $yr[$i];?>"><?php echo $yr[$i];?></option>
  131.        <?php
  132.        }//else
  133.     }//for
  134.   }//if 
  135.   else
  136.    {
  137.     for($j=0;$j<count($yr);$j++)
  138.     {
  139.     ?>
  140.    <option value="<?php echo $yr[$j];?>"><?php echo $yr[$j];?></option>
  141.     <?php
  142.     }
  143.    }
  144.     ?>
  145.     </select>
  146. </td></tr>
  147.     </table><br />
  148.       <center>
  149.    <input type="submit" name="gen_invoice"  id="gen_invoice" value="Generate Invoice" class="button" /></center>
  150. <br />
  151.   <?php
  152.   if(isset($_POST['billmonth']) && isset($_POST['billyear']) && isset($_POST['gen_invoice']))
  153.   {
  154.   ?>
  155. <table border="0" cellspacing="1" cellpadding="2" class="bg1" align="center">
  156. <tr>
  157. <td><div align="center">Serial No</div></td>
  158. <td><div align="center">Customer Name</div></td>
  159. <td><div align="center">Building Name</div></td>
  160. <td><div align="center">Floor No</div></td>
  161. <td><div align="center">Block Name</div></td>
  162. <td><div align="center">Rent(Rs.)</div></td>
  163. <td><div align="center">Payment</div></td>
  164. </tr>  
  165. <?php
  166.  $flblno=mysql_query("select build_name,floor_no,block_name,pms_rental.rent,pms_rental.block_id,pms_customer.cust_name,pms_customer.cust_id from pms_block,pms_customer,pms_rental where pms_block.block_id=pms_rental.block_id and pms_rental.cust_id=pms_customer.cust_id") or die('Unable to perform the operation');
  167.   $cou=1;
  168.    while($fl=mysql_fetch_object($flblno))
  169.   {
  170.    ?>
  171.   <tr class="bg2">
  172.   <td><?php echo $cou;?></td>
  173.   <td><?php echo $fl->cust_name;?></td>
  174.   <td><?php echo $fl->build_name;?></td>
  175.   <td><?php echo $fl->floor_no;?></td> 
  176.   <td><?php echo $fl->block_name;?></td>
  177.   <td><?php echo $fl->rent;?></td>
  178.   <td><a href="" name="pay_link" onclick="javascript:payment();">Payment</a></td></tr>
  179.   <input type="hidden" name="custno"  value="<?php echo $fl->cust_id;?>" />
  180.   <input type="hidden" name="blno"  value="<?php echo $fl->block_id;?>" />
  181.   <?php
  182.   $cou++;
  183.   }
  184.   ?>
  185. <?php
  186. }
  187.  ?>
  188. </table>
  189. <?php
  190.  }
  191. ?>
  192. </form>
  193. </html>
  194. <?php
  195. }
  196.  
  197. else
  198. {
  199.    header("location:login_index.php");
  200. }
  201. ?>                 
  202.  
  203.  
Apr 8 '08 #1
1 1691
ronverdonk
4,258 Expert 4TB
Do you mean that you don't get the names of the hidden fields in your $_POST array or that these fields ar in the $_POST array but have no value assigned to them?

Ronald
Apr 9 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
8
by: Matt Herson | last post by:
I have been trying to find a way to use JavaScript to change the value of a hidden field on submit. I am already invoking a JavaScript to handle the validation on submit. The reason I need to...
4
by: Fred | last post by:
Hi, i know how to pass a value from Javascript to ASP with a hidden field into a form and submitting it, or with cookies, but here i have to pass a lot of data in an array. There is a list of...
3
by: Itai | last post by:
I have an aspx file named index.aspx which contains two ‘form' sections, one that has the runat=server attribute (e.g From1) and one which is a regular HTML form (e.g SignInForm). I am trying...
9
by: Randell D. | last post by:
Folks, I have a large amount of values to store (we're talking tens, if not hundreds of bytes). I need this for a client side application - ignore the security consequences for the moment -...
4
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be...
5
by: Ian Davies | last post by:
Hello I wish to use J.S. to obtain the screen ht and put this value into a hidden field for posting. so that I can then use it in a php file. A simplified script of what I am trying to do is...
5
by: dmorand | last post by:
I'm having a strange issue with a form I'm developing. I'm saving some values to hidden fields when a user clicks a button. I setup a function which gets ran on submission of the form, but I also...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.