Question

HTML has JavaScript link to call PHP to generate more HTML ... and the JavaScript in that doesn't work -- HELP!

Asked by: DanielWilson

I'm working a PHP site with tons of JavaScript that I took over from another company.  The fun doesn't end!

Last night's issue which is still giving me trouble is a javascript calendar.

This form is supposed to allow an indefinite number of detail lines to be added.  You put in details then click the "add another " link and another set of boxes shows up.

The last company hard-coded 5 DIVs keeping all but the first hidden, so the "add another" link just un-hid the next DIV.  the problem?  There were only 5.

I now have the "add another link" doing an AJAX call to have a PHP function deliver another KB of HTML to add another set of payment boxes.  It works great ...

EXCEPT ...

The set of boxes is supposed to include a JavaScript calendar.  When I call the PHP function during page load, the java script loads and works.  Code is below, but it gives me a functioning JS calendar.
<script language="JavaScript">
1
2 new tcal ({
3 'formname': 'add_payment',
4 'controlname': 'payment_date1'
5 });
</script>
which produces:
<img id="tcalico_0" class="tcalIcon" alt="Open Calendar" onclick="A_TCALS['0'].f_toggle()" src="img/cal.gif"/>

But ... if I include that code in what the PHP function returns to the AJAX call, the Javascript still produces the <img> tag, but it fills the entire <HTML> instead of being where it's supposed to be.  The browser keeps trying to pull back what it's supposed to get ... though FireBug/FirePHP show that the appropriate HTML block to fill the <DIV> has been returned.

Any ideas?

thanks!

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-09-03 at 11:59:05ID24705663
Topics

JavaScript

,

Asynchronous Javascript and XML (AJAX)

,

PHP Scripting Language

Participating Experts
1
Points
500
Comments
23

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Calendar with php.
    Hi guys! I have a calendar that I downloaded that id like to use in a php/html page. Ive just made a basic html to test it. ============================================================ <html> <head><title>Basic Example</title></head> <bo...
  2. onClick to execute an external javascript on a PHP based w…
    The modified for PHP javascript below executes when page is loaded. I need to execute the script when it is clicked. I would like to open a new window and execute the script. Something like <?php echo "<tr><td><a href='#' onclick=\"window.open('h...
  3. onClick
    hi, I want to return a vaiable from onClick to use it in PHP code .. Example $var = 0; onClick ( $var = 1 ) echo "Variable value= ".$var; result Variable value=1 how I can achieve that !! Thanks

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Slick812Posted on 2009-09-03 at 17:09:45ID: 25256093

hello Daniel Wilson, , I have read your question info, but I do not have the ability to "get" what or where your problem might be. You sound as if you have used Ajax before with successful results. I do not really understand when you say -
"produces the <img> tag, but it fills the entire <HTML> instead of being where it's supposed to be."
For many if not all of my Ajax responseText calls I use an innerHTML =  , , like -
domC.innerHTML = ajaxObj.responseText;
And in the responseText  there are no <html> or <body> tags, are you sending back ajax as the entire page, or just the -
<img id="tcalico_0" class="tcalIcon" alt="Open Calendar" onclick="A_TCALS['0'].f_toggle()" src="img/cal.gif"/>
if your ajaxObj.responseText, seems correct, maybe you have left out some ending tag like </div>  or </table>, which can completely throw off the page rendering. Also I have had problems with " and ' (double and single quote) in my PHP, , forgetting to escape it  for html output.

 

by: DanielWilsonPosted on 2009-09-03 at 17:39:44ID: 25256185

Sorry it's confusing.

I'm admittedly weak in JavaScript and Ajax.  Perhaps if I could explain the question better I'd know the solution!

You suggest an ending /div or /table may be missing ... let me try to check that.

Failing that, perhaps I need to try to replicate it with a simpler example ... also one that I can show without providing a login to my customers site-in-progress.

 

by: Slick812Posted on 2009-09-03 at 20:46:57ID: 25256719

You might show us the String building PHP code for the "Ajax Send Back" string. You may have forgot to exit the PHP.
Here is some code that I have used for Ajax send back

header("Cache-Control: no-cache, must-revalidate"); // Cache control headers
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");   // For Internet Explorer
 
$SendBack = '<imag id="'.$array1[0].'" class="'.$array1[1].'" src="'.$array1[2].'"/>';
 
header('Content-Length: '.strlen($SendBack));
header('Connection: close'); // Indicate we will close the connection
echo $SendBack; // for Ajax responseText
//exit(0); // You MUST exit the process, if there is more PHP code after, that you DO NOT want to process

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:

Select allOpen in new window

 

by: DanielWilsonPosted on 2009-09-04 at 00:14:10ID: 25257352

I don't think failure to exit is the problem as there's nothing done except a return from the function and an end of a switch statement after the echo.

I'm getting real close to having a simplified example at http://www.gccswb.com/test/TestBoxes.php

PHP code for that page is:

<?php
	require_once('AddTestBox.php');
	
?>
		<html><head><title>Testing the boxes</title>
		
		<link rel="stylesheet" href="../css/calendar.css" type="text/css" />
		<script language="JavaScript" src="../js/calendar_us.js"></script>
		
<script>
function ShowNextPayment(){
	controlNo= parseInt($('#theValue').val());
	
	controlNo=controlNo+1;
	
	jQuery.ajax({
		type: "GET",
		url: "AddTestBox.php?option=AddPaymentBox&PaymentNum="+controlNo,
		dataType: "html",
		success: function(response){				
 
		$('#DivPayment'+controlNo).html('');
		$('#DivPayment'+controlNo).html(response);
	},
	error: function(){
		alert("Error occured during Ajax request...");
	}
	});	
	
	$('#theValue').val(controlNo)
}
</script>
		</head><body><div>
		<form name="add_payment" id="add_payment" method="post" action="">
<?php 
	AddTestBox(1);
	echo <<<END
		<div class="v_12_2" style="padding:8px"><a href="javascript:void(0);" onclick="ShowNextPayment(); return false;"><strong>Add another box</strong></a></div>
		 <div class="clear"></div>
 
		 </form>
		</div></body></html>
END;
	
?>
	

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:

Select allOpen in new window

 

by: DanielWilsonPosted on 2009-09-04 at 00:16:51ID: 25257363

I am currently getting (in this test) a JS error:
$ is not definedShowNextPayment()TestBoxes.php (line 8)function onclick(event) {     ShowNextPayment();     return false; }(click clientX=81, clientY=121)3 (line 2)      controlNo= parseInt($('#theValue').val());\r\n

i don't know why it works in the live one but not here.  Frankly, i don't know what $ is supposed to mean.  i said I was weak in JS!

and the page that makes the HTML to add in is:

<?php
 
	function AddTestBox($iPaymentNum){
		$iNextPaymentNum = $iPaymentNum+1;
		$iJSPayNum = $iPaymentNum -1;
		
		$str = <<<TESTBOX
		<div>
	        <div style="padding-bottom:5px; padding-top:5px"><strong>Test $iPaymentNum:</strong></div>
	        <div class="left_board_payment"  style="width:120px">Payment Date:</div>
				<div class="left" style="padding-left:10px; width:150px"><input name="payment_date[]" type="text" class="input_field" id="payment_date$iPaymentNum" value="
TESTBOX;
		$str.= date('m/d/Y').'"  readonly=""/>';
		$str.= <<<PAYBOX2
			<script language="JavaScript">
	new tcal ({
		'formname': 'add_payment',
		'controlname': 'payment_date$iPaymentNum'
	});	</script>
	</div>
          <div id="DivPayment$iNextPaymentNum">
          </div>
    </div>
PAYBOX2;
 
		echo $str;
	}
	
	
	switch($_REQUEST['option']){
		case 'AddPaymentBox':
			AddPaymentBox($_REQUEST['PaymentNum']);
		
	}
?>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:

Select allOpen in new window

 

by: Slick812Posted on 2009-09-04 at 07:50:18ID: 25260253

??? as to the $ and javascript, as far as I know, , in some browsers, the $ is a syntax shortcut for  document.getElementById . . But There seems to be some variety on how this is implemented?
so you might try and change -
controlNo= parseInt($('#theValue').val());
to -
controlNo= parseInt(document.getElementById('#theValue').val());

I personally do not use the $ as a shortcut, because some browsers are finaky with it, I am sorry but I do not have experience with the ramblings of the javascript $ .. Also jQuery may have something to do with the $, but I have not used jQuery for quite some time.
Also, you have the jQuery, but I do not see a javascript load for a jQuery JS file, or maybe its in the calender JS?

you might try and change the
 $('#DivPayment'+controlNo).html(response); to

document.getElementById('#DivPayment'+controlNo).innerHTML = response;

 

by: DanielWilsonPosted on 2009-09-04 at 07:55:11ID: 25260286

yeah, it's jquery.  Got that part solved just a few minutes ago.

Now I've got the error being replicated here.  
http://www.gccswb.com/test/TestBoxes.php


Updated code here:

<?php //parent page, TestBoxes.php
	require_once('AddTestBox.php');
	
?>
		<html><head><title>Testing the boxes</title>
		
		<link rel="stylesheet" href="../css/calendar.css" type="text/css" />
		<script type="text/javascript" src="../js/jquery.js"></script>
		<script language="JavaScript" src="../js/calendar_us.js"></script>
		
<script>
function ShowNextPayment(){
	controlNo= parseInt($('#theValue').val());
	
	controlNo=controlNo+1;
	
	jQuery.ajax({
		type: "GET",
		url: "AddTestBox.php?option=AddPaymentBox&PaymentNum="+controlNo,
		dataType: "html",
		success: function(response){				
 
		$('#DivPayment'+controlNo).html('');
		$('#DivPayment'+controlNo).html(response);
	},
	error: function(){
		alert("Error occured during Ajax request...");
	}
	});	
	
	$('#theValue').val(controlNo)
}
</script>
		</head><body><div>
		<form name="add_payment" id="add_payment" method="post" action="">
		<input type="hidden" value="1" id="theValue" />
<?php 
	AddTestBox(1);
	echo <<<END
		<div class="v_12_2" style="padding:8px"><a href="javascript:void(0);" onclick="ShowNextPayment(); return false;"><strong>Add another box</strong></a></div>
		 <div class="clear"></div>
 
		 </form>
		</div></body></html>
END;
	
?>
	

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:

Select allOpen in new window

 

by: DanielWilsonPosted on 2009-09-04 at 07:55:57ID: 25260296

and the worker page code ...

<?php //worker page AddTestBox.php
 
	function AddTestBox($iPaymentNum){
		$iNextPaymentNum = $iPaymentNum+1;
		$iJSPayNum = $iPaymentNum -1;
		
		$str = <<<TESTBOX
		<div>
	        <div style="padding-bottom:5px; padding-top:5px"><strong>Test $iPaymentNum:</strong></div>
	        <div class="left_board_payment"  style="width:120px">Payment Date:</div>
				<div class="left" style="padding-left:10px; width:150px"><input name="payment_date[]" type="text" class="input_field" id="payment_date$iPaymentNum" value="
TESTBOX;
		$str.= date('m/d/Y').'"  readonly=""/>';
		$str.= <<<PAYBOX2
			<script language="JavaScript">
	new tcal ({
		'formname': 'add_payment',
		'controlname': 'payment_date$iPaymentNum'
	});	</script>
	</div>
          <div id="DivPayment$iNextPaymentNum">
          </div>
    </div>
PAYBOX2;
 
		echo $str;
	}
	
	
	switch($_REQUEST['option']){
		case 'AddPaymentBox':
			AddTestBox($_REQUEST['PaymentNum']);
		
	}
?>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:

Select allOpen in new window

 

by: Slick812Posted on 2009-09-04 at 08:04:05ID: 25260364

?? I was looking more at your code, you have -
<a href="javascript:void(0);" onclick="ShowNextPayment(); return false;">

I think I would write this as -

<a href="#" onclick="ShowNextPayment();">

or

<a href="javascript:ShowNextPayment();">

 

by: DanielWilsonPosted on 2009-09-04 at 08:12:24ID: 25260443

OK, that's more compact ... and no worse.  Hasn't corrected the calendar issue though.

Note that if I omit the calendar script when the thing is called via javaScript, it adds the next DIV blocks without difficulty.

Modified AddTestBox code below:

function AddTestBox($iPaymentNum){
		$iNextPaymentNum = $iPaymentNum+1;
		$iJSPayNum = $iPaymentNum -1;
		
		$str = <<<TESTBOX
		<div>
	        <div style="padding-bottom:5px; padding-top:5px"><strong>Test $iPaymentNum:</strong></div>
	        <div class="left_board_payment"  style="width:120px">Payment Date:</div>
				<div class="left" style="padding-left:10px; width:150px"><input name="payment_date[]" type="text" class="input_field" id="payment_date$iPaymentNum" value="
TESTBOX;
		$str.= date('m/d/Y').'"  readonly=""/>';
		if ($iPaymentNum ==1)
		$str.= <<<PAYBOX2
			<script language="JavaScript">
	new tcal ({
		'formname': 'add_payment',
		'controlname': 'payment_date$iPaymentNum'
	});	</script>
PAYBOX2;
		$str.= <<<TESTBOX3
	</div>
          <div id="DivPayment$iNextPaymentNum">
          </div>
    </div>
TESTBOX3;
 
		echo $str;
	}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:

Select allOpen in new window

 

by: DanielWilsonPosted on 2009-09-04 at 08:14:37ID: 25260464

But ... the inclusion of that calendar JavaScript makes it so that only the calendar <img> tag (emitted by the new tcal() JS call)  shows up in the page.

And I've repeatedly counted the <div> and </div> tags to verify that they match.

 

by: Slick812Posted on 2009-09-04 at 08:53:30ID: 25260821

?? I am not liking your (to me) over use of <div> and style in your return ajax, For testing and development, I would eliminate all decoration HTML and style, untill I get it working.

first you start with a do-nothing <div>, which might be left out, because the html is already in a DIV <div id="DivPayment2">, ,
next I might change the -
<div style="padding-bottom:5px; padding-top:5px"><strong>Test $iPaymentNum:</strong></div>
to -
<b>Test $iPaymentNum:</b><br/>

as to your problem?
It seems that the added ajax javascript is not being executed, and I do not remember using DHTML in this way, I have added ajax return javascript functions in Clicks, but not as a function call from the added HTML. I will look at my notes to see about this, You may need to add a JS eval() to tell the browser to do this, but I do not remember the syntax (if there is syntax) for this.

 

by: Slick812Posted on 2009-09-04 at 09:08:01ID: 25260980

You might try and add a function call to your jQuery.ajax() for the return

success: function(response){                            
$('#DivPayment'+controlNo).html('');
$('#DivPayment'+controlNo).html(response);
doAddCalender(controlNo);
}

the doAddCalender(controlNo);  function would then write the Calender javascript to the place where you need it,,
You may need to add a <span>  or <div> with an ID at the location you want the calender to be at.

 

by: Slick812Posted on 2009-09-04 at 09:09:50ID: 25261003

OH I forgot to say, do NOT have the -
<script language="JavaScript">
 new tcal ({  'formname': 'add_payment',
  'controlname': 'payment_date$iPaymentNum'
  });</script>

in your return Ajax html

 

by: DanielWilsonPosted on 2009-09-04 at 09:44:19ID: 25261291

Below is my doAddCalendar function ... with which I get the same results:


too many <div> tags?  I agree, but look at a sample of what I inherited!

<div class="" align="left">
       <div>
         <div class="f_r_f_p_head">
           <div class="f_r_f_p_head2">
             <div class="f_r_f_p_head3">
               <h3>Board A Payment</h3>
             </div>
           </div>
         </div>
       </div>
       
       <div>
         <div class="f_r_f_p_body">
           <div class="f_r_f_p_body1">
             <div class="f_r_f_p_body2">
               <div class="f_r_f_p_body3">
                 <div class="f_r_f_p_body4" style="padding-top:5px">
                   <div id="DivResp"></div>
                   <div id="DivForm"><div style="padding:10px">

function doAddCalendar(iPaymentNum){
	new tcal ({  'formname': 'add_payment',
		  'controlname': 'payment_date' +iPaymentNum
		  });
}

                                              
1:
2:
3:
4:
5:

Select allOpen in new window

 

by: Slick812Posted on 2009-09-04 at 10:50:06ID: 25261844

OUCH, IT HURTS, LOL, so many DIV, probably doing a whole bunch of nothing. .
OK, first some Javascript tips and hints, , In your doAddCalendar  function, You have just copyed the new tcal, but unlike where it is in your HTML (where it works), it is in a function now, and the JS engine has no way of knowing where to write any output from new tcal() and ignores it, ,  so you must always tell it where to place the output, , I am sorry, but I have no Idea about the way tcal works, so it may not be useable for a function, BUT, you need to tell the JS engine where to write, , the jquery  uses this -
$('#DivPayment'+controlNo).html(response);
as a Div ID placement for HTML
$('#CalDiv'+iPaymentNum).html(new tcal ({ 'formname': 'add_payment',
                  'controlname': 'payment_date' +iPaymentNum
                  }));
but this adds some multiple inner workings (both tcal and jquery) so I have little confidence this may work. Anyway You will have to add a <div> with something like <div id="CalDiv2"></div> in your ajax return HTML, where you want the new calender to be, with the correct  CalDiv2  number for that div. I use document.getElementByID() for my calls, but if the juery $ works, use it.

So you may want to test it first with string -
function doAddCalendar(iPaymentNum){
$('#CalDiv'+iPaymentNum).html('<b>New String to see</b>');
}

next you may test the out put of new tcal
function doAddCalendar(iPaymentNum){
var ncal = new tcal ({  'formname': 'add_payment','controlname': 'payment_date' +iPaymentNum});
if (ncal.length<5) {ncal='ERROR, no TCAL OUTPUT'}
$('#CalDiv'+iPaymentNum).html(ncal);
}

 

by: Slick812Posted on 2009-09-04 at 11:02:36ID: 25261944

I forgot -
if (typeof ncal !== "string") {ncal='ERROR, no String Output'} else if (ncal.length<5) {ncal='ERROR, no TCAL OUTPUT'}

 

by: DanielWilsonPosted on 2009-09-04 at 11:06:50ID: 25261967

Putting in "this is the doAddCalendar output", that shows up exactly where we would expect.

but ... the tcal call still blows it up.

>>next you may test the out put of new tcal

OK, I'll try that next ...

<div id="DivPayment2">
<div>
<div style="padding-bottom: 5px; padding-top: 5px;">
</div>
<div class="left_board_payment" style="width: 120px;">Payment Date:</div>
<div class="left" style="padding-left: 10px; width: 150px;">
<input id="payment_date2" class="input_field" type="text" readonly="" value="09/04/2009" name="payment_date[]"/>
<div id="CalDiv2">this is the doAddCalendar output</div>
</div>
<div id="DivPayment3"> </div>
</div>
</div>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:

Select allOpen in new window

 

by: DanielWilsonPosted on 2009-09-04 at 11:13:17ID: 25262010

capturing new tcal() in ncal and putting it into the div didn't work either.  Still blew it up.

So ... there's something this tcal is doing that is not getting along at all with the other JavaScript.

Is there a fundamentally different way to do this?  to add an indefinite number of payment boxes, each having its own calendar control?

btw, thanks for all your help so far!

 

by: Slick812Posted on 2009-09-04 at 11:47:15ID: 25262271

I was wondering why you were using Ajax for adding these extra boxes? but I did not really look at your code for that.
You might could add the boxes with just javascript function, but that seems to not be working as you have it now. I tried to look at the JS code in the  calendar_us.js  , but I do not have time or motivation to dissect it. But it uses some windows Global calls and it has this -
this.e_iframe = document.createElement("IFRAME");

For me, IFrames really changes the way this may be used in javascript function. . . I have no experience with that as a complex function use. Since it uses document.createElement calls, I doubt it can work as a "string" insert as we are trying to do. . .
There is the possibility of having several many <div> with calenders that are not shown (hidden or non) in style, and then show them with JS. But you could only have a fixed max number. And this may be less than elegant in how it works. Have you looked on the js calender site at
http://www.softcomplex.com/products/tigra_calendar/
for how-to do what you are trying?

 

by: Slick812Posted on 2009-09-04 at 11:58:32ID: 25262349

here is some code from the tiara calender site, I guess it makes dynamic calenders?

<script language="JavaScript">
		var N_CALNUM = 1;
		function f_createContent() {
			var e_div = f_getElement('container');
			e_div.innerHTML += N_CALNUM
				+ '. <input type="text" name="testinput' + N_CALNUM + '" value="" />'
				+ '<img title="Open Calendar" class="tcalIcon" onclick="A_TCALS[\'myCalID' + N_CALNUM + '\'].f_toggle()" id="tcalico_myCalID' + N_CALNUM + '" src="img/cal.gif"/><br />';
 
			new tcal ({
				// form name
				'formname': 'testform',
				// input name
				'controlname': 'testinput' + N_CALNUM,
				// set unique ID to identify the elements
				'id': 'myCalID' + N_CALNUM
			});
			
			N_CALNUM++;
		}
		function f_removeContent() {
			var e_div = f_getElement('container');
			e_div.innerHTML = '';
			window.A_TCALS = null;
			window.A_TCALSIDX = null;
			N_CALNUM = 1;
		}
	</script>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:

Select allOpen in new window

 

by: DanielWilsonPosted on 2009-09-04 at 12:42:52ID: 25262733

Working with Tigra now ...

Thanks!

 

by: DanielWilsonPosted on 2009-09-19 at 09:30:17ID: 25373562

I think I'll need to use a completely different method as I can't get this to work.

Thanks for the help, though.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...