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

ASP rich text editor (almost works)

Hello,

I've been last 8 hours (without standing up) trying to connect a rich text editor to my ASP-page.
I chose the rich text editor from http://www.kevinroth.com/rte/demo.htm.

I wanna upload the text to a field in a table in MSAccess database called data.mdb

The table name is tblNewsC and into the field "Article"

I editied the code from kevinroth's demo to a page I already programmed called "add_news.asp"
and then a page named "insert_news.asp" insert the records to the database but the original kevinroth demo is just one page with onclick="return" effect.

The results are that I am adding an empty record to the database but the text in the rich text box doesn't appear.

this is the code I used for the demo:

(note: I renamed add_news.asp and insert_news.asp with a "c" so add_newsc.asp and insert_newsc.asp are not typos)

<HTML>
<script language="JavaScript" type="text/javascript" src="html2xhtml.js"></script>
<script language="JavaScript" type="text/javascript" src="richtext_compressed.js"></script>
<BODY>
<%

dim sContent
      
inputnum = request.querystring("inputnum")
If IsEmpty(inputnum) or inputnum = "" then


%>

 <!-- Begin form code -->


<form name=RTEDemo metho="POST" action="insert_newsc.asp?inputnum=1">
<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
      //make sure hidden and iframe values are in sync for all rtes before submitting form
      updateRTEs();
      
      return true;
}

//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, encHTML)
initRTE("./images/", "./", "", true);
//-->
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>

<script language="JavaScript" type="text/javascript">
<!--
//build new richTextEditor
var rte1 = new richTextEditor('rte1');
<%
if request.form("rte1") = "" then
      sContent = "here's the " & chr(13) & """preloaded <b>content</b>"""
      sContent = RTESafe(sContent)
else
      sContent = RTESafe(request.form("rte1"))
end if
%>
rte1.html = '<%=sContent%>';
//rte1.toggleSrc = false;
rte1.build();
//-->
</script>
<p><input type="submit" name="submit" value="Submit" /></p>
</form>
<%
function RTESafe(strText)
      'returns safe code for preloading in the RTE
      dim tmpString
      
      tmpString = trim(strText)
      
      'convert all types of single quotes
      tmpString = replace(tmpString, chr(145), chr(39))
      tmpString = replace(tmpString, chr(146), chr(39))
      tmpString = replace(tmpString, "'", "&#39;")
      
      'convert all types of double quotes
      tmpString = replace(tmpString, chr(147), chr(34))
      tmpString = replace(tmpString, chr(148), chr(34))
'      tmpString = replace(tmpString, """", "\""")
      
      'replace carriage returns & line feeds
      tmpString = replace(tmpString, chr(10), " ")
      tmpString = replace(tmpString, chr(13), " ")
      
      RTESafe = tmpString
end function
%>

</body>
</html>
<%End if%>


... AND THE CODE FOR THE INSERT_NEWSC.ASP


<%
function RTESafe(strText)
      'returns safe code for preloading in the RTE
      dim tmpString
      
      tmpString = trim(strText)
      
      'convert all types of single quotes
      tmpString = replace(tmpString, chr(145), chr(39))
      tmpString = replace(tmpString, chr(146), chr(39))
      tmpString = replace(tmpString, "'", "&#39;")
      
      'convert all types of double quotes
      tmpString = replace(tmpString, chr(147), chr(34))
      tmpString = replace(tmpString, chr(148), chr(34))
'      tmpString = replace(tmpString, """", "\""")
      
      'replace carriage returns & line feeds
      tmpString = replace(tmpString, chr(10), " ")
      tmpString = replace(tmpString, chr(13), " ")
      
      RTESafe = tmpString
end function

sContent=Request.Form("sArticle")


' Hér vantaði vísun í hvaða databeis átti að opna auk driversins
' sem þarf að nota fyrir access

Set connectionToDatabase=Server.CreateObject("ADODB.Connection")
connectionToDatabase.ConnectionTimeout=40
connectionTodatabase.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
      Server.MapPath("data.mdb") & ";"
      

sqlStatement="INSERT INTO tblNewsc(sArticle) VALUES ('"& sArticle & "')"

' Hér var ritvilla sqlStatemnet í stað sqlStatement
Set recordSet = connectionTodatabase.Execute(sqlStatement)


connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

I must be not so far from it if the database is taking empty records, am I?

0
rrenderman
Asked:
rrenderman
  • 5
  • 5
  • 3
  • +2
1 Solution
 
BadotzCommented:
Perhaps a question posted to www.kevinroth.com is in order here?
0
 
b0lsc0ttIT ManagerCommented:
rrenderman,

No reason to rush off somewhere else right away.  The forum on that site may be a good place to look but I'll assume you came here after already spending sometime on your own and at that site.

I am not familiar with that editor so I may have to look into this a bit to help.  It sounds like the code came with a simple example though.  Does that work?  If you didn't try it then you might want to do that.  It is often easier to learn about something starting with a basic page than to try to start off by putting it in an already complex page.

Are you getting an error?  Make sure that you don't use On Error Resume Next to "hide" some errors that would help us.  Also if using IE you should have the "Use Friendly HTTP error messages" box unchecked.

If you are getting a record added then is it only the one field for the rich text or are there others that should have info too?  This would help to identify if the problem is just with the values that go in the field for the rich text or if there is a more general problem.  It may help if you show or let us know what fields are in the form.  The code above seems to use some server script for that part too.  I couldn't really tell what fields are coming from the form and what info they had.

You could certainly hold off a bit on the details in case an expert already is familiar with this editor and script.  Otherwise we will need some more details to get "caught up." :)

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
rrendermanAuthor Commented:

Hi b0lsc0tt and thanx very much for me comment,

I already read some help topics on the page where I found the code but there are more
pages there I havn't read.

Since I got an empty record I thought I must be so close to it.

I always have "not show friendly error message" in the browser to see the errors I have.

I have other fields that I will add after I solve this but I decided to start on this where the.

Actually I think it's just matter of finding out where I should replace the variables in the code
for example:

THE (request.form("rte1"))... should I replace the "rte1" with my name of the field "article"..
OR is it the RTESafe(sContent) where I should replace with "articel"...

Can't it be it's just small things like that I have to do right.... or maybe there's more to it :)



0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
b0lsc0ttIT ManagerCommented:
It may just be small things.  For example I noticed a typo and missing double quotes in the form tag (see below).  The quotes usually can be left out but the typo would be a problem since it was the word method.

<form name="RTEDemo" method="POST" action="insert_newsc.asp?inputnum=1">

Fix those and review your code for others.  Let me know if that is it.  If not then what field in the form are you using?  Look at the html source to make sure the tag (i.e. input or textarea) looks good.  What is its name?

From your ASP it seems like it may by named rte1 but make sure it has a name property in the form field's html.

RTESafe is a function, right?  What if you don't use it do you still get the empty value?  You should add a Response.Write to the code in certain places so you can see if the value never exists, gets lost somewhere, or is there but just not going to the database.

It would still help to get an explanation of what is going on.  For example what is sContent and how is it used?  Which functions are specific to the text editor you are using?

Hopefully it is just the typo. :)  Let me know if you have a question.

bol
0
 
CWS (haripriya)Commented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: b0lsc0tt {http:#20827935}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

cyberwebservice
Experts Exchange Cleanup Volunteer
0
 
BadotzCommented:
So, where is the solution to this question, exactly?
0
 
CWS (haripriya)Commented:
I found some useful advice in b0lsc0tt's comment {http:#20827935} so I recommended to accept this comment.

I will leave it to the moderators.
0
 
BadotzCommented:
Fine, but shouldn't @rrenderman decide this? And is "good advice" really a solution?

I'm not after poinks here, just curious about the value of this question for future viewers.
0
 
b0lsc0ttIT ManagerCommented:
Thanks Cyberwebservice for your time cleaning up! :)

I hesitate to reply for the obvious reason that it will seem self-serving but I do have a response or two that may help.

I would prefer if the Asker were to participate and reply to my comments or even let us know the status of this.  However that isn't an option.  The cleanup person just needs to go with what is available here.

If it helps there is a solution in the comment with the good advice.  The typo for the method will be a problem and needed to be fixed.  I'll admit it might not be the only problem but we can't know it wasn't the fix.  It isn't unreasonable to think that would fix this, and if it didn't, then the other info I provided would help narrow down the cause or even solution.

I am fine with either having this accepted as recommended or deleted with no points refunded.  There is definitely info here that can help others though.  I hope this opinion helps.  Thanks again for your time cleaning Cyberwebservice.  I think this may be your first time cleaning but you have done a good job (I am not just saying that for this question ;)).

bol

p.s.  Moderator, this is not objection to the CV recommendation.
0
 
BadotzCommented:
As far as I can tell, the only good advice boils down to spell- and grammar-checking.

While we may never know the outcome of this conundrum, I still see no reason not to simply delete the question.

I know that I have no authority in the final decision, but if I cannot see any value in this Q & A, surely others will have the same problem?

btw: Is there no way for anyone at EE to "reach out" and send an email to an unresponsive asker?
0
 
b0lsc0ttIT ManagerCommented:
Moderator,

This is not renewed activity in the question.  Also I am not objecting to the recommendation.

Badotz,

I think your points are valid and well made.  The moderator will look at them and does consider them.  In cases where it could go either way they often stick with the CV's recommendation but I have definitely seen them change it.  I'll be interested to see what is decided here.  I do feel there is value in what was posted but I understand what you say.

>> Is there no way for anyone at EE to "reach out" and send an email to an unresponsive asker? <<

The Admins have access to that info and can send an email.  The zone advisors and moderators can post a member comment which will send an email notice.  EE has also started to send automatic notices that have resulted in a lot of Askers coming back to close or participate.  Unfortunately there is no way to compel the member to respond and participate.

bol
0
 
BadotzCommented:
Right, thanks.

bol: I'm not just stirring the pot, and please don't think I'm attacking you or anyone else at EE. I really am trying to be impartial, for what its worth.

There is a kindler, gentler Badotz that gets to come out and play, once in awhile ;-)

0
 
b0lsc0ttIT ManagerCommented:
Moderator,

Ignore this please.  Still no objection.

Badotz,

I believe you and really do think you had a good reason to post.  I have posted in similar cases and even if it wasn't followed it was nice to have the chance and I know it was heard.

I was actually thinking how nice this conversation was and how reasonable your responses.  I didn't want to mention it and see a good thing go away. ;)  No apology or explanation needed and thanks for the last comment.  It cracked my up a bit because I was thinking the same thing. :D

This Badotz is really nice to have around.  I have always thought you had some good and important contributions to make as an expert here.  Your history here and accomplishments are evidence of it.

See you around,

bol
0
 
CWS (haripriya)Commented:
>>"good advice" really a solution?
yes it is, sometimes :)
There is no direct solution for the asker's question, he has to try the suggestions given by the experts and respond to it. He failed to do so.

>>just curious about the value of this question for future viewers.
There are lot of questions PAQed which just had some typo.

Normally for this particular question, we have to choose one among these 3 options, 'Delete-No refund', 'Split', 'Accept'.  I recommended 'Accept' because there is some valuable information in b0lsc0tt's comment and I still stick to that.

I just told my opinion about closing this question.
This is just a recommendation and the final decision is not in our hands :)

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: b0lsc0tt {http:#20827935}

Thanks.
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 5
  • 5
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now