Link to home
Start Free TrialLog in
Avatar of rrenderman
rrenderman

asked on

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?

Avatar of Badotz
Badotz
Flag of United States of America image

Perhaps a question posted to www.kevinroth.com is in order here?
Avatar of b0lsc0tt
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
Avatar of rrenderman
rrenderman

ASKER


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 :)



ASKER CERTIFIED SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
So, where is the solution to this question, exactly?
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.
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.
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.
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?
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
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 ;-)

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
>>"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.
Forced accept.

Computer101
EE Admin