Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript calendar & tables

Status
Not open for further replies.

GiddyRob

Programmer
Aug 25, 2005
37
GB
Hi,

I have some code that creates calendar objects the problem is that I want the links to the calander stored in a table populated dynamically (using a while loop). The code below shows the field that creates the link button and text field that the date goes into. Basically when the user clicks on the link it brings up a calendar in another window. The user can pick a date and this is put in the textfield.

Code:
<td><form name=\"form\"><span class=\"style2\">&nbsp;<input type=\"Text\" name=\"text\" value=\"\"><a href=\"javascript:call.popup();\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Click Here to Pick up the date\"></a>&nbsp;</span></form></td>

The "call" in the javascript is a calendar object called "call".

Code:
<script language=\"JavaScript\">
  
  var call = new calendar1(document.forms['form'].elements['text']);
   call.year_scroll = true;
   call.time_comp = false;
  

</script>

It uses 'form' & 'text' which are the names of the form and the textfield. I need it to create a different calendar object for each row. At the moment I get an error that says "Error 'document.forms.form.elements.text' is null or not an object". Both links open the same calendar object and it just populates the first textfield in the table.

The image shows what is going on.

calendar.gif


Does anyone know how I can fix this problem so that I can have as many or little calendar objects in the table.

Any help would be great

Cheers

Rob
 
If you place each Form in <td>, you need to name your Form differently.
 
How do I do that? I tried to do it with php by appending a number on each form and using a count but the javascript thing that makes the object did not recognise the form name anymore.
 
Not enough code to really know what is going on so I will say this.
Using the name 'form' for a form is a bad idea as well as using the name 'text' for your other field. You may run into problems with those words being reserved or otherwise misinterpreted by one browser or another. At the very least preface them with something like 'myform' so they are clearly not a command to be interpreted.

Now, do you really want to create multiple calendars or do you mean you want one calendar that pops up for each field you want to link it to so that it will populate the correct field? I would think the latter as multiple calendar objects would get confusing on the screen as they might have several open and forget which one is for what field.

I suggest that you make a function that calls your calendar code. When you dynamically build your form put in the call to your function and pass in the name of the input box it is associated with. No need to pass in the whole thing like document.forms['form'].elements['text'], just the name will do. You may have to modify the calendar to target the input field more directly but it is easy to do.

Did you design the calendar? It is a slick looking design.


Paranoid? ME?? WHO WANTS TO KNOW????
 
Hi,

I used the code for the calendar cos I am a bit of a newbie to javascript. The code works by getting the name of the form and the name of the textfield, I guess it would work if I could make the form and textfield names different. Like I said earlier it doesn't like the names when I append php to them e.g.

Code:
<?php
echo"<form name=\"myform".$num."\" etc";

$num++;
>?


Code:
<script language=\"JavaScript\">
  
  var call = new calendar1(document.forms['myform'].elements['mytext']);
   call.year_scroll = true;
   call.time_comp = false;
  

</script>

I guess I don't need multiple calendars but it does need to pass back the date to the correct textfield in the table.

Can you see a way round this by passing the form & textfield names? Can I append a number in Javascript like in php so that the names are recognised.

Driving me mad cos its almost working.

Cheers

Rob
 
Yes you can append the names with javascript. It should append with php also if you are generating the field from a php page. It really depends on how your code is setup to generate the form.

Do you have multiple forms on the page? Or would you only be generating new forms in order to have multiple calendars?
It may not be necessary to generate multiple forms, only the additional fields on the existing form.

Would have to see more code to understand the proces of how you are generating the HTML to know where/how to insert the values for the field names.



Paranoid? ME?? WHO WANTS TO KNOW????
 
I am using multiple forms. a form for each field that has the textfield and link to the calendar. The code below is for the whole page it includes pretty much everything. The code for the calendar comes from


Code:
<?php
session_start();

$pageselect="adminpooledjobs";//so the correct sqls from sqlqueries.php are executed
include('sqlqueries.php');//plugs in the sqlqueries.php file

function newjobheader(){

//The code below echos out the header fields for the new jobs
echo"<table class=\"style1\" id=\"table0\" width=\"580\" border=\"2\" cellspacing=\"2\" cellpadding=\"0\"><tr bgcolor=\"#1C78B7\">
                    <td><div align=\"center\">Job ID</div></td>
                    <td><div align=\"center\">Client</td>
                    <td><div align=\"center\">Date Created</div></td>
                    <td><div align=\"center\">Desc Summary</div></td>
                    <td><div align=\"center\">Type ID</div></td>
                    <td><div align=\"center\">Problem ID</div></td>
                    <td><div align=\"center\">Comments</div></td>
					<td><div align=\"center\">Exp Date</div></td>
                    <td><div align=\"center\"></div></td></tr>";

}//end of newjobheader function

function assignedjobheader(){

//The code below echos out the header fields for the new jobs
echo"<table table class=\"style1\" id=\"table1\" width=\"740\" border=\"2\" cellspacing=\"2\" cellpadding=\"0\"><tr bgcolor=\"#1C78B7\">
                    <td><div align=\"center\"><span class=\"style1\">Job ID</span></div></td>
                    <td><div align=\"center\"><span class=\"style1\">Client</span></div></td>
                    <td><div align=\"center\"><span class=\"style1\">Date Created</span></div></td>
					<td><div align=\"center\"><span class=\"style1\">Desc Summary</span></div></td>
					<td><div align=\"center\"><span class=\"style1\">Technician</span></div></td>
                    <td><div align=\"center\"><span class=\"style1\">Type ID</span></div></td>
                    <td><div align=\"center\"><span class=\"style1\">Problem ID</span></div></td>
					<td><div align=\"center\"><span class=\"style1\">Expected Date</span></div></td>
                    <td><div align=\"center\"><span class=\"style1\">Comments</span></div></td>
					<td><div align=\"center\"><span class=\"style1\"></span></div></td>
                    <td><div align=\"center\"><span class=\"style1\"></span></div></td></tr>";

}//end of newjobheader function

function newjobrecords(){

global $row;
global $count;
//<input type=\"hidden\" name=\"description\" value=\"".$row[2]."\">
echo"<td><span class=\"style2\">&nbsp;$row[0]</span></td>
	 <td><span class=\"style2\">&nbsp;$row[4]</span></td>
	 
	 <td><span class=\"style2\">&nbsp;$row[3]</span></td>
	 <td><span class=\"style2\">&nbsp;<a href=\"javascript:Avaa('description.php?id1=$row[0]&id2=$row[2]')\">$row[1]</a></span></td>
	 <td><span class=\"style2\">&nbsp;$row[5]</span></td>
	 <td><span class=\"style2\">&nbsp;$row[6]</span></td>
	 <td><span class=\"style2\">&nbsp;$row[7]</span></td>
	 <td><form name=\"myform\"><span class=\"style2\">&nbsp;<input type=\"Text\" name=\"mytext\" value=\"\"><a href=\"javascript:call.popup();\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Click Here to Pick up the date\"></a>&nbsp;</span></form>
	 <script language=\"JavaScript\">
	 
	 var call = new calendar1(document.forms['myform'].elements['mytext']);
				call.year_scroll = true;
				call.time_comp = false;
			
	 </script>
	 </td>
	 <td><form name=\"assignjob".$row[0]."\" method=\"post\" action=\"\" onSubmit=\"\">
		 <input type=\"hidden\" name=\"assignthejob\" value=\"".$row[0]."\">
		 <input type=\"submit\" name=\"assign\" value=\"Assign\">
		 </form>    	
	 </td>
	 </tr>\n";
$count++;	
}

function adminjobrecords(){
//	 <input type=\"hidden\" name=\"description\" value=\"".$rowassigend[2]."\">
global $rowassigend;
echo"<td><span class=\"style2\">&nbsp;<font color=\"$rowassigend[10]\">$rowassigend[0]</font></span></td>
	 <td><span class=\"style2\">&nbsp;<font color=\"$rowassigend[10]\">$rowassigend[6]</font></span></td>

	 <td><span class=\"style2\">&nbsp;<font color=\"$rowassigend[10]\">$rowassigend[3]</font></span></td>
	 <td><span class=\"style2\">&nbsp;<font color=\"$rowassigend[10]\">$rowassigend[1]</font></span></td>
	 <td><span class=\"style2\">&nbsp;<font color=\"$rowassigend[10]\">$rowassigend[4]</font></span></td>
	 <td><span class=\"style2\">&nbsp;<font color=\"$rowassigend[10]\">$rowassigend[7]</font></span></td>
	 <td><span class=\"style2\">&nbsp;<font color=\"$rowassigend[10]\">$rowassigend[8]</font></span></td>
	 <td><span class=\"style2\">&nbsp;<font color=\"$rowassigend[10]\">$rowassigend[5]</font></span></td>
	 <td><span class=\"style2\">&nbsp;<font color=\"$rowassigend[10]\">$rowassigend[9]</font></span></td>
	 <td align=\"center\"><input name=\"Submit\" type=\"submit\" value=\"Edit\">
	 <td align=\"center\"><input name=\"Submit\" type=\"submit\" value=\"Close\"></td>
	 </tr>\n";
	 
}
//&nbsp; needed to create a space at the beginning of the table
//$rowassigend[10] gets the colour from the database
?>

<html>
<head>

<title>Pooled Jobs</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK REL="[URL unfurl="true"]http://128.1.1.68/hdesk/"[/URL]
       HREF="images/favicon.ico">
<script language="JavaScript" src="calendar/calendar1.js"></script><!-- Date only with year scrolling -->	
   
<script type="text/javascript">
	function Avaa(newin) {
		flyout=window.open(newin,"flyout","resizable=no,scrollbars=no,width=325,height=330,top=200,left=230")
		//flyout is an object that can be closed etc, newin is for the URL, flyout is the name, and the rest is the window properties
	}
</script>

<script src="sorttable.js">//this is used to sort the tables</script>

</head>

<body bgcolor="#1c78b7" onLoad='initTable("table0"); initTable("table1");'>

<?
	include("menu/header.php");
?>

<table align="center" bgcolor="white" width="620" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="20" height="20" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20" valign="top"><img src="images/topleft.jpg" width="20" height="20"></td>
        </tr>
    </table></td>
    <td width="580" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="580" height="20">&nbsp;</td>
        </tr>
    </table></td>
    <td width="20" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20" valign="top"><img src="images/topright.jpg" width="20" height="20"></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td height="20" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="20" height="20">&nbsp;</td>
      </tr>
    </table></td>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <td width="580" height="20">
		   <?php
		  newjobheader();//function displays the new job header info
		  
		  while($row = mysql_fetch_array($newadminjobs, MYSQL_NUM)){

			newjobrecords();
			?>
			  <script language="JavaScript">
		 
//			var call = new calendar1(document.forms['form'].elements['text']);
		//		call.year_scroll = true;
		//		call.time_comp = false;
			
		//document.write(document.forms['form']);
				
			  </script>
		  <?
		  }//end of while
		 echo"</table>";//end of the table new jobs
		  ?>
	
		  </td>

    </table></td>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20">&nbsp;</td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td height="20" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20" valign="top"><img src="images/bottomleft.jpg" width="20" height="20"></td>
        </tr>
    </table></td>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="580" height="20">&nbsp;</td>
        </tr>
    </table></td>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20" valign="top"><img src="images/bottomright.jpg" width="20" height="20"></td>
        </tr>
    </table></td>
  </tr>
</table>
<p>
</p>
<!--assigned jobs------------------------------------------------------------------------------------------->	
	
<table align="center" bgcolor="white" width="780" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="20" height="20" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20" valign="top"><img src="images/topleft.jpg" width="20" height="20"></td>
        </tr>
    </table></td>
    <td width="740" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="740" height="20">&nbsp;</td>
        </tr>
    </table></td>
    <td width="20" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20" valign="top"><img src="images/topright.jpg" width="20" height="20"></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td height="20" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="20" height="20">&nbsp;</td>
      </tr>
    </table></td>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
          <td width="740" height="20">
		   
		<?php
		  assignedjobheader();//function displays the new job header info
		  
		  while($rowassigend = mysql_fetch_array($assignedadminjobs, MYSQL_NUM)){
		  
			adminjobrecords();
		  
		  }
  
		  echo"</table>";
		  
		?>
		
		  </td>

    </table></td>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20">&nbsp;</td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td height="20" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20" valign="top"><img src="images/bottomleft.jpg" width="20" height="20"></td>
        </tr>
    </table></td>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="740" height="20">&nbsp;</td>
        </tr>
    </table></td>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="20" height="20" valign="top"><img src="images/bottomright.jpg" width="20" height="20"></td>
        </tr>
    </table></td>
  </tr>
</table>
	
<?
	include("menu/footer.php");	
?> 
</body>
</html>

The function that creates the table I am having a problem with is "newjobrecords()"

Any more info give me a shout.

Cheers

Rob
 

When you tried this:
<?php
echo"<form name=\"myform".$num."\" etc";

$num++;
>?

Did you view the code to see if it appended the expected value? Where was $num coming from? I do not see it in your code.

You have a globally defined value $count. Try inserting that in there instead.

Once you get your form fields properly generating with unique id's then you will need to alter your calling script to accept passed in values. Right now it is fixed so it will always go to the same form and field name.

var call = new calendar1(document.forms['myform'].elements['mytext']);
call.year_scroll = true;
call.time_comp = false;

This should not be in this function because you are re-declaring it exactly the same way each time you build a new form.

What they do in the Tigra Calendar sample page is to declare a bunch of calendar objects in a row. They obviously knew how many fields they had so this was easy.
The link in the form was sequential.
javascript:cal1.popup();
javascript:cal2.popup();
javascript:cal3.popup(); etc...

Then they had one function create all the calendar objects sequentially.
var cal1 = new calendar1(document.forms['tstest'].elements['input1']);
cal1.year_scroll = true;
cal1.time_comp = false;
var cal2 = new calendar1(document.forms['tstest'].elements['input2']);
cal2.year_scroll = false;

My suggestion to you is to create all of your forms using your $count value to give sequential numbers to the name of the form, the name of the input field and to the call for the popup. After they are all created, use another function to dynamically generate the calendar objects with sequential VAR names, form names and input field names.


Paranoid? ME?? WHO WANTS TO KNOW????
 
Hi,

sorry I put a slightly older version of my code in there. Yeah that is what I have been thinking but I can't quite work out how to do it in javascript. Can I just append a count on the call object? ie

Code:
<?php
echo"<a href=\"javascript:call.$count.popup();\"> etc ";
?>

Would that append $count? Have to bere with me cos I am just starting out in the world of javascript. I know what I wanna do but dont have a scooby's about the codes syntax.

I will have a go at writing a function. Am i right in assuming that the javascript function will be inside the while loop so that a new object is created on each pass?

Thanks a lot for your help so far, very very much appreciated.

Cheers

Rob
 
Hi again,

I have tried to set it up so I can test the appended numbers but it has now stoped working altogher. The calendar will not pop up and it says "Error: 'call' is undefined". I have used $num as the count variable and set it to 0 to start with. The code below is a snippet of what I have changed.

Code:
echo"<td><span class=\"style2\">&nbsp;$row[0]</span></td>
	 <td><span class=\"style2\">&nbsp;$row[4]</span></td>
	 
	 <td><span class=\"style2\">&nbsp;$row[3]</span></td>
	 <td><span class=\"style2\">&nbsp;<a href=\"javascript:Avaa('description.php?id1=$row[0]&id2=$row[2]')\">$row[1]</a></span></td>
	 <td><span class=\"style2\">&nbsp;$row[5]</span></td>
	 <td><span class=\"style2\">&nbsp;$row[6]</span></td>
	 <td><span class=\"style2\">&nbsp;$row[7]</span></td>
	 <td><form name=\"myform".$num."\"><span class=\"style2\">&nbsp;<input type=\"Text\" name=\"mytext".$num."\" value=\"\"><a href=\"javascript:call.popup();\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Click Here to Pick up the date\"></a>&nbsp;</span></form>
	 <script language=\"JavaScript\">
	 
	 var call = new calendar1(document.forms['myform0'].elements['mytext0']);
				call.year_scroll = true;
				call.time_comp = false;
				
				
)
	 </script>
	 </td>
	 <td><form name=\"assignjob".$row[0]."\" method=\"post\" action=\"\" onSubmit=\"\">
		 <input type=\"hidden\" name=\"assignthejob\" value=\"".$row[0]."\">
		 <input type=\"submit\" name=\"assign\" value=\"Assign\">
		 </form>    	
	 </td>
	 </tr>\n";
$num++;

}

Think this thing is trying to finish me off :)

Cheers

Rob
 
All you are really doing here is building a text string that will be echoed to the browser where it will then become the javascript command so you would approach it the same way you were in PHP.
Something like this:
echo"<a href=\"javascript:cal".$count.".popup();\">"
The only real difference is that I added in the close quotes after cal so that the PHP value can be entered. You did it within the quotes which means it would get treated as literal text of cal$count instead of cal1.

Then you have to decide how to build the calendar objects.
Your best bet is to write it in PHP just like your other function, echo out the opening script tag for javascript, then setup a loop to build your calendar objects loop from 1 to $count. and echo each line out to the browser, then echo out the closing script tag.


Paranoid? ME?? WHO WANTS TO KNOW????
 
OK.
Re-thinking.

I WAS suggesting you build all of your calendar objects in a separate function but that is NOT necessary. Sorry.

Now for the current problem.
I did not see in your code that $num was instantiated anywhere or incremented. Does it exist yet?

You put the incremental value on the form and field name but it also needs to go into the onclick event, into the field where you instantiate the object, pass the form/field names to it and where you set it's properties.

Also, you did not close off the script tag or the whole string with a trailing quote.

Try this:
echo"<td><span class=\"style2\">&nbsp;$row[0]</span></td>
<td><span class=\"style2\">&nbsp;$row[4]</span></td>
<td><span class=\"style2\">&nbsp;$row[3]</span></td>
<td><span class=\"style2\">&nbsp;<a href=\"javascript:Avaa('description.php?id1=$row[0]&id2=$row[2]')\">$row[1]</a></span></td>
<td><span class=\"style2\">&nbsp;$row[5]</span></td>
<td><span class=\"style2\">&nbsp;$row[6]</span></td>
<td><span class=\"style2\">&nbsp;$row[7]</span></td>
<td><form name=\"myform".$num."\"><span class=\"style2\">&nbsp;<input type=\"Text\" name=\"mytext".$num."\" value=\"\"><a href=\"javascript:cal".$cnt.".popup();\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Click Here to Pick up the date\"></a>&nbsp;</span></form>
<script language=\"JavaScript\">

var cal".$num." = new calendar1(document.forms['myform".$num."'].elements['mytext".num."']);
cal".$num.".year_scroll = true;
cal".$num.".time_comp = false;
</script>"


)

Paranoid? ME?? WHO WANTS TO KNOW????
 
Whoops, I am going to screw you up. I was only see part of the code.

Try this: But first, what is that close paren just before the </script> tag? Might need to remove that.

echo"<td><span class=\"style2\">&nbsp;$row[0]</span></td>
<td><span class=\"style2\">&nbsp;$row[4]</span></td>
<td><span class=\"style2\">&nbsp;$row[3]</span></td>
<td><span class=\"style2\">&nbsp;<a href=\"javascript:Avaa('description.php?id1=$row[0]&id2=$row[2]')\">$row[1]</a></span></td>
<td><span class=\"style2\">&nbsp;$row[5]</span></td>
<td><span class=\"style2\">&nbsp;$row[6]</span></td>
<td><span class=\"style2\">&nbsp;$row[7]</span></td>
<td><form name=\"myform".$num."\"><span class=\"style2\">&nbsp;<input type=\"Text\" name=\"mytext".$num."\" value=\"\"><a href=\"javascript:cal".$cnt.".popup();\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Click Here to Pick up the date\"></a>&nbsp;</span></form>
<script language=\"JavaScript\">

var cal".$num." = new calendar1(document.forms['myform".$num."'].elements['mytext".num."']);
cal".$num.".year_scroll = true;
cal".$num.".time_comp = false;
)
</script>
</td>
<td><form name=\"assignjob".$row[0]."\" method=\"post\" action=\"\" onSubmit=\"\">
<input type=\"hidden\" name=\"assignthejob\" value=\"".$row[0]."\">
<input type=\"submit\" name=\"assign\" value=\"Assign\">
</form>
</td>
</tr>\n";
$num++;

}

Paranoid? ME?? WHO WANTS TO KNOW????
 
Yo,

its working like a dream!

Thank you so so so much, that has saved me a lot of books to read through.

Hope I can help someone if they have a similar problem like this in the future.

Happy coding

Regards

Rob
 
You are very welcome. Glad it worked.
Much of the time I can test on my own end to see but with yours I did not have all of the code and you are running PHP which I cannot run on my server at work. :(

This is just another case of mixing server side and client side scripting though and I have run into it so many times I know generally what to look for. :)


Paranoid? ME?? WHO WANTS TO KNOW????
 
Doh, Im back again.

I can't seem to work out how to pass the value of the textfield (date) to a variable in php. I know how to do it with static textfield but can't guess what the code is to do it dynamically.

Code:
function newjobrecords(){

global $row;

//<input type=\"hidden\" name=\"description\" value=\"".$row[2]."\">
echo"<td><span class=\"style2\">$row[0]</span></td>
	 <td><span class=\"style2\">$row[4]</span></td>	 
	 <td><span class=\"style2\">$row[3]</span></td>
	 <td><span class=\"style2\"><a href=\"javascript:Avaa('description.php?id1=$row[0]&id2=$row[2]')\">$row[1]</a></span></td>
	 <td><span class=\"style2\">$row[5]</span></td>
	 <td><span class=\"style2\">$row[6]</span></td>
	 <td><span class=\"style2\">$row[7]</span></td>
	 <td><form name=\"myform".$row[0]."\" method=\"post\" action=\"\" onSubmit=\"\">
	 		<span class=\"style2\">
	 		<input type=\"Text\" name=\"mytext".$row[0]."\" size=\"8\"value=\"\">&nbsp;<a href=\"javascript:call".$row[0].".popup();\"><img src=\"images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Click Here to Pick up the date\"></a>
			</span>	 
	 </td>
	 <td>
		 	<input type=\"hidden\" name=\"expdate\" value=\"mytext".$row[0].".value\">
		 	<input type=\"submit\" name=\"assign\" value=\"Assign\">
	 	</form>    	
	 </td>
	 <script language=\"JavaScript\">
			var call".$row[0]." = new calendar1(document.forms['myform".$row[0]."'].elements['mytext".$row[0]."']);
				call".$row[0].".year_scroll = true;
				call".$row[0].".time_comp = false;
	 </script>
	 </tr>\n";

}

As you can see I have slightly changed the code so that the submit button is contained in the same form. The code below is meant to get the date so I can put it in a variable.

Code:
if(isset($_POST['assign'])){//handle the form when the user presses the button

 $date=($_POST['mytext'.$row[0]]);
 echo"$date";	

}

I even tried creating a hidden input that used a static name and the value of ''mydate'.$row[0]' but it just returned the name of the mydate ie 'mydate3'

Tried the phpfreaks forum before I bothered you again but they don't seem to have a clue there.

Could I possibly borrow a little more of your knowledge then I am done and dusted.

Cheers

Rob
 
You end up with lots of forms on the page since you are generating one form for each field that has a calendar attached. Are all of these submit buttons working separately? Or should you realistically have only one submit for the entire page?

What I mean is, will a submit from a single form only need to retrieve the one textfield value for that form or when ANY submission takes place you need to get all the date fields from the whole page?



Paranoid? ME?? WHO WANTS TO KNOW????
 
each row has a submit button in its own form which is catched by the isset. It will get a hidden field that contains the jobid $row[0] and use this to know which record to update in the database. I just need to put the date that comes from the textfield into a php variable.

Hope that makes it a little clearer

Cheers

Rob
 
Try building the fieldname into your onsubmit function while you are dynamically building the form.
EX: onsubmit="myfunction('mytext0')"

You do not show how the function that would use this value gets called. Your onsubmit and action= statements are blank so as far as I can see the code you are using to try and set the value is never even called.

Is that code from a separate page where you are processing the data? That makes more sense to me but my knowledge of PHP is very limited.

Is there ever only going to be one single date field selected? Or will multiple date fields be selected and you will have to retrieve them all from the page you submit to?



Paranoid? ME?? WHO WANTS TO KNOW????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top