Hi
I am facing big problem.
I am making a web site for a travel agent.
I am making a form where the Admin will create a new tour.
One form contain all information related to new tour.
On another Form the Admin will enter the Itinerary for that tour.
I have 4 fields (Day no, City, Itinerary, Night Stay City).
As the tour can be of variable days. It may be for 7 days or 10 or 15 days, so accordingly I did the code for Admin to add and remove the text boxes according to tour's no of days.
Now I want to save the whole itinerary in a table.
My question is how can i send the whole bunch of array (suppose the tour is or 10 days then 10 itinerary * 4 columns ) to another form for inserting into table using the $_POST thru a URL. And another thing is how should i receive this bunch of array on the posted form and save into table.
I am giving the code which i have created please let me know how can i take the values in array and pass to another page.
This is a code for inserting itineraries for a tour in a particular tourname.
This is my javascript code which create the textboxes after clicking Add Button
<script type="text/javascript">
$(document).ready(function(){
var counter = 2;
$("#addButton").click(function () {
if(counter>30){
alert("Only 30 textboxes allow");
return false;
}
var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.after().html(
'<input type="text" name="textbox' + counter +'" id="textbox' + counter + '" value="'+ counter + '" >' +
'<input type="text" name="textbox' + counter +'" id="textbox' + counter + '" value="" >'+
'<input type="text" name="textbox' + counter +'" id="textbox' + counter + '" value="" >'+
'<input type="text" name="textbox' + counter +'" id="textbox' + counter + '" value="" >' );
newTextBoxDiv.appendTo("#TextBoxesGroup");
counter++;
});
$("#removeButton").click(function () {
if(counter==1){
alert("No more textbox to remove");
return false;
}
counter--;
$("#TextBoxDiv" + counter).remove();
});
$("#getButtonValue").click(function () {
var msg = '';
for(i=1; i<counter;> {
msg += "\n No. of day #" + i + " : " + $('#textbox' + i).val();
}
alert(msg);
});
});
</script>
Now I am giving you the html code for text boxes.
<form id="form1" name="form2" method="post" onsubmit="" action="addtour_itinerary.php" >
<table width="717" height="123">
<!--DWLayoutTable-->
<tr>
<td height="27" colspan="4" align="center" valign="middle" bgcolor="#FFEAFF">Enter Itinerary Details</td>
</tr>
<tr>
<td height="27" colspan="2" valign="top" bgcolor="#FFEAFF">Name of Tour (category)</td>
<td colspan="2" align="center" valign="middle" bgcolor="#FFFFCC"><label>
<?php echo $_SESSION['tourname'];??></label></td>
</tr>
<tr>
<td width="61" height="27" valign="top" bgcolor="#E1E1E1">Days</td>
<td width="140" valign="top" bgcolor="#E1E1E1">City</td>
<td width="345" valign="top" bgcolor="#E1E1E1">Itinerary</td>
<td width="145" valign="top" bgcolor="#E1E1E1">Night Stay</td>
</tr>
<tr>
<td height="48" colspan="4" valign="top" bgcolor="#E1E1E1">
<!--<input type="text" name="days" id="days" />-->
<div id="TextBoxesGroup">
<div id="TextBoxDiv1">
<label></label>
<input type='text' id='dayNo' name="itinerary[]" >
<input type="text" id='cityName' name="itinerary[]">
<input type='text' id='schedule' name="itinerary[]">
<input type='text' id='nightStay' name="itinerary[]">
</div>
</div>
<input type='button' value='Add Button' id='addButton'>
<input type='button' value='Remove Button' id='removeButton'>
<input type='button' value='Get TextBox Value' id='getButtonValue'>
<input type="submit" name="submit" id="submit" value="Submit" />
</td>
</tr>
</table>
</form>
Now i want to ask does i have created the array of textboxes correctly or not. what is wrong with my code. how i should collect the values entered into the textboxes and pass to the php page so that i can be saved in table. How can i save the send array into table.
Can i pass the whole array thru session and how to receive those values, i would like to know what should i write in VALUES( ) after Getting the array values.
Thanks in Advance.