LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[Webdev] Javascrip and php array problem

[Webdev] Javascrip and php array problem

AJ McKee aj.mckee at nmtbmedia.com
Tue Jan 21 10:02:34 GMT 2003


Hi All I have a rather confusing problem here. I have enclosed some
simple sample code below so you can get an Idea of theproblem.

Basically a user selects an option from a drop down box. That option is
then passed onto php which looks at the value and dependant on the value
should print out the same number of input boxes that the value
represents.

That's is fine.

Now these boxes are to hold a date, lets call them eventdate. That's
fine. Using phps inbuilt arraying I can pass the values as an array to
the next part of the array. 

Except for one liitle problem I am having. The requirements of the site
state that for each input box I have a link shoul be created which will
display a drop down calendar. This makes it very easy as well to control
the input of the date. SO a little googleing as I am no good at
javascript at all and I found this
http://www.mattkruse.com/javascript/calendarpopup/ (I am using <Div>)
which is exactly what I was looking for. 

Now the problem. If I have 5 input boxes all must have unique names so
the javascript can relate to it an write the selected date to the
correct input box. But then that removes my functionality of using an
array in php upon form submission as then I would have to rename each
input box. So I am wondering if there is anyway around this.

Belwo is the sample code which will probally explain better. 

Thanks in advance.
AJ

if($Submit)
	{
	$query1 = mysql_query("Select * from Types where Type='$Type'");
	$resultset1 = mysql_fetch_array($query1);
	$amount_of_input_boxes = $resultset1[LineCount];
	?>
	  <SCRIPT LANGUAGE="JavaScript">
	  <?php
	  for($inputbox = 1; $inputbox <= $amount_of_input_boxes ;
$inputbox++)
			{
			print("var cal1x = new
CalendarPopup(\"calendar$inputbox\");\n");
			}
	?>
	 </SCRIPT>
	<form name="form1" id="form1" method="post"
action="/enter-bet/wizard-2.php">
	<input name="clientid" type="hidden" id="clientid" />
    <?php
	for($inputbox = 1; $inputbox <= $amount_of_input_boxes ;
$inputbox++)
			{
			print("<input type=\"text\"
name=\"eventdate[$inputbox]\" vlaue=\"\"> \n");
			print("<A HREF=\"#\"
onClick=\"cal1x.select(document.forms[0].eventdate,'anchor1x','MM/dd/yyy
y'); return false;\" NAME=\"anchor1x\"
ID=\"anchor1x\">select</A></p>\n");
			}
	?>
	</form>
		<?php
		for($inputbox = 1; $inputbox <= $amount_of_input_boxes ;
$inputbox++)
		{
		print("<DIV ID=\"calendar$inputbox\"
STYLE=\"position:absolute;visibility:hidden;background-color:white;layer
-background-color:white;\"></DIV>\n");
		}
		?>
		<?php
	} 





More information about the Webdev mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell