Page 1 of 1

[HELP]Getting value from multiple forms

Posted: Mon Jan 24, 2011 10:16 pm
by aicrop
Hi! guys

I need some help how to view all the forms that has been filled already by the user

phpex1.php

Code: Select all

<center>
<head>


</head>


<div class="art-content">
            
                       
                                      
                       
                                            
                                                
                                
												
											<form  name="signup" id="signup" method="post" action="phpex1input.php">  
										 
												   
										
												
												 
								<font face="Verdana" size="4" color="#008080">Enter number of customers:
								</font></b>&nbsp;<input type="text" name="t1" id="t1" size="20"><input type="submit" name="submit" value="Register" tabindex="8" ><input type="reset" value="Reset" name="B2">
												
											
											</form> 
                                           
                                    
                                     
                       </center>
Image

Code: Select all

<?php
				
					
						
		
					if($_POST['submit'])	{
				
						$count = 0;
					
						$t1 = $_POST['t1'];
						
						
						while ($count != $t1){
					
						echo "<form method='POST' action=''>
	
	<table border='0' width='68%' bordercolorlight='#003300' bordercolordark='#009933'>
		<tr>
			<td width='21%' bgcolor='#339966'><b>
			<font face='Verdana' size='2' color='#99FFCC'>Customer's Name: 
			</font></b></td>
			<td width='58%' bgcolor='#99FFCC'>
			<font color='#008080'face='Verdana'> 
			<input name='T2' size='20' style='background-color: #66FF66'></font></td>
		</tr>
		<tr>
			<td width='21%' bgcolor='#339966'><b>
			<font face='Verdana' size='2' color='#99FFCC'>Item Bought:</font></b></td>
			<td width='58%' bgcolor='#99FFCC'>
			<font color='#008080' face='Verdana'>
			<span style='background-color: #66FF66'><font color='#99FFCC'>
	<select size='1' name='D1' style='color: #008080'><option>Grocery Package 1</option><option>Grocery Package 2</option>
	<option>Grocery Package 3</option><option>Grocery Package 4</option></select></font></span></font></td>
		</tr>
		<tr>
			<td width='21%' bgcolor='#339966'><b>
			<font face='Verdana' size='2' color='#99FFCC'>Quantity:</font></b></td>
			<td width='58%' bgcolor='#99FFCC'>
			<font color='#008080' face='Verdana'> 
			<input name='T1' size='5' style='background-color: #66FF66'></font></td>
		</tr>
		<tr>
			<td width='21%' bgcolor='#339966'><b>
			<font face='Verdana' size='2' color='#99FFCC'>Mode of Payment: 
			</font></b></td>
			<td width='58%'bgcolor='#99FFCC'><font face='Verdana'>
			<font color='#008080'> <span style='background-color: #66FF66'> <input type='radio' name='mode' value='Cash' checked></span></font><font size='2' color='#008080'> Cash
			</font><span style='background-color: #66FF66'><font color='#008080'>
	<input type='radio' name='mode' value='Credit Card'></font></span><font size='2' color='#008080'> Credit Card
			</font><span style='background-color: #66FF66'><font color='#008080'>
	<input type='radio' name='mode' value='COD'></font></span><font size='2' color='#008080'> Cash on Delivery</font></font></td>
		</tr>
		<tr>
			<td width='21%' bgcolor='#339966'><b>
			<font face='Verdana' size='2' color='#99FFCC'>Discount Types:</font></b></td>
			<td width='58%' bgcolor='#99FFCC'><font face='Verdana'>
			<font color='#008080'> 
			<span style='background-color: #66FF66'> 
			<input type='checkbox' name='Discount1' value='Senior Citizen'></span></font><font size='2' color='#008080'>Senior Citizen
			</font><span style='background-color: #66FF66'><font color='#008080'>
	<input type='checkbox' name='Discount2' value='Membership Card'></font></span><font size='2' color='#008080'>Membership Card
			</font><span style='background-color: #66FF66'><font color='#008080'>
	<input type='checkbox' name='Discount' value='Promo Values'></font></span><font size='2' color='#008080'>Promo Values</font></font></td>
		</tr>
		<tr>
			<td colspan='2' bgcolor='#99FFCC'>
			<p align='right'><font color='#008080' face='Verdana'>
			<input type='reset' value='Reset' name='B2'></font></td>
		</tr>
	</table>
</form>";
					
			
					
		$count++;		
					
				}	
					
					}
?>	
	
Image
can any one give me some pointers or example on how to view the values from this multiple forms

thanks

Re: [HELP]Getting value from multiple forms

Posted: Mon Jan 24, 2011 11:42 pm
by josh
You cannot post multiple forms. You'll need to have it be one forum that just looks like "two forms". In fact all you should need is 2 or more tables to create the illusion. 1 actual form to surround them.

Re: [HELP]Getting value from multiple forms

Posted: Tue Jan 25, 2011 6:27 am
by aicrop
thank you very much for the idea!

Re: [HELP]Getting value from multiple forms

Posted: Tue Jan 25, 2011 7:03 am
by raj23
Hi,
You can do this using jquery. I have given some ideas

$("form").submit(function()
{
combineAndSendForms();
return false;
});
function combineAndSendForms()
{
var $newForm = $("<form></form>")
.attr({method : "POST", action : ""})
$(":input:not(:submit, :button)").each(function() {
$newForm.append($("<input type=\"hidden\" />")
.attr('name', this.name)
.val($(this).val())
);
});
$newForm
.appendTo(document.body)
.submit()
;
}
I hope this will be helpful for you.

By
Drupal website development