• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Script Error when calling Function - Again

Well I thought I could modify the test code to do what I want but I am getting a script error again.

I am trying to insert a signture with a date stamp below it upon clicking the submit buttom.

The text test works fine as far as the insert goes - I still have a problem with the format of the image and date.

<script language="JavaScript1.2"><!--
function insertText(form) {
 sText = "<img height="77" src="'../../client_files/editor_images/schwab.gif" width="180" border="0"' /> <br>" + FormatDateTime(now) + ";
 eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);
}
-->
</script>

Previous Question:
http://www.experts-xchange.com/Web/Web_Languages/ASP/Q_21418868.html#13968352

0
cooperrd
Asked:
cooperrd
  • 11
  • 7
1 Solution
 
fritz_the_blankCommented:
Try this:
<script language="JavaScript1.2"><!--
function insertText(form) {
 sText = "<img height=\"77\" src=\"../../client_files/editor_images/schwab.gif\" width=\"180\" border=\"0\" /> <br>" + FormatDateTime(now) + ";
 eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);
}
-->
</script>


FtB
0
 
fritz_the_blankCommented:
The issue is that you are using " " delimiters for your string. However, you are also using " " to enclose parameters within your string. I used the \ to escape the " marks so that you won't have issues.

FtB
0
 
cooperrdAuthor Commented:
Fritz,

I am still getting Error: Object Expected Code:0 at Line 191 (191 is the submit statement)
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
fritz_the_blankCommented:
Do you have a link for me to look at?

FtB
0
 
cooperrdAuthor Commented:
http://www.ccshost.com/wyndston_sleep/schd/Login.asp

Login test@test.com

pw: test

Go to Notations and in the list click on any Add/Edit Report.  You will see the add link at the top middle of the title bar.
0
 
fritz_the_blankCommented:
Okay, line 69 is the issue. Now when I look at this, you have this line over two lines rather than on one:
             sText = "<img height=\"77\" src=\"../../client_files/editor_images/schwab.gif\" width=\"180\" border=\"0\" /> <br>" + FormatDateTime(now) + ";
             eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);


So either these both belong on the same line without the ; or you want to lose the + after the FormatDateTime(now)

Does that make sense?

FtB
0
 
cooperrdAuthor Commented:
This is the script that I started with (that works) when you look at my code "sText" is begins line 217 and Line 218 begins with "eWebEditPro etc..."

I tried removing the " + " behind FDT(Now) No Luck - Then I removed the Semi Colon after FDT(Now) + "; still no luck

In answer to your question nothing about scripting makes sense to me.  I have always had problems with the syntax.


<script language="JavaScript1.2"><!--
function insertText(form) {
  sText = "test";
  eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);
}
-->
</script>
0
 
fritz_the_blankCommented:
Okay, let's try these two:

1) without line breaks:

sText = "<img height=\"77\" src=\"../../client_files/editor_images/schwab.gif\" width=\"180\" border=\"0\" /> <br>" + FormatDateTime(now) + eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);


2) with line breaks

sText = "<img height=\"77\" src=\"../../client_files/editor_images/schwab.gif\" width=\"180\" border=\"0\" /> <br>" + FormatDateTime(now);
           eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);


FtB
0
 
fritz_the_blankCommented:
As an aside, JavaScript is very tricky--it is case sensitive and very picky about syntax. That is good because it is unambiguous, but it is bad because it can be very hard at times.

FtB
0
 
fritz_the_blankCommented:
Hey! It seems to be working now?

FtB
0
 
cooperrdAuthor Commented:
Ok, neither of the two above worked - but when I removed the line break and the time stamp the image inserts.

Here is where I am. - Is there a differt way to insert the date stamp - I mean other than tehe FormatDateTime?

 sText = "<img height=\"77\" src=\"../../client_files/editor_images/schwab.gif\" width=\"180\" border=\"0\" />";
           eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);
0
 
fritz_the_blankCommented:
I am sorry, I didn't see that. FormatDateTime() is not a JavaScript supported function!

How about:

sText = "<img height=\"77\" src=\"../../client_files/editor_images/schwab.gif\" width=\"180\" border=\"0\" />" + " " + Date();
           eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);


FtB
0
 
cooperrdAuthor Commented:
Perfect! Can I just re-insert the <br> or is there a different break for JavaScript?
0
 
fritz_the_blankCommented:
Oh sure. It is not br, but \n  I think. So, like this:

sText = "<img height=\"77\" src=\"../../client_files/editor_images/schwab.gif\" width=\"180\" border=\"0\" />" + "\n " + Date() + "\n";
           eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);

FtB
0
 
cooperrdAuthor Commented:
It's still not putting it below the image - I have your last code on the page now.
0
 
fritz_the_blankCommented:
My bad. You do use <br> here because you are not adding breaks to the string but to the html...

sText = "<img height=\"77\" src=\"../../client_files/editor_images/schwab.gif\" width=\"180\" border=\"0\" />" + "<br /> " + Date() + "<br />";
           eWebEditPro.instances[eWebEditPro.event.srcName].editor.pasteHTML(sText);


FtB
0
 
cooperrdAuthor Commented:
Fritz,

You are the Best!  

Thank you so much!
0
 
fritz_the_blankCommented:
Glad to have helped and good luck!

FtB
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 11
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now