|
-
Feb 1st, 2002, 05:09 PM
#1
Thread Starter
Addicted Member
JavaScript & Form Posting
Hi everyone,
I have a page that includes a Rich Text editor in the HTML (like in Hotmail) so that a user can create nicely formatted documents. I also have, on that same page, a form that includes data such as the page title etc... which I want to send to a ASP page to process the data. However, the RT editor uses JavaScript (the text in javascript is called "idContent.document.body.innerHTML"
My question is, is there any way in which I can send the string in javascript (above) as part of my form to the ASP page for processing by using a submit button.
One solution that I do have (far from ideal) is to create two pages, one where the title etc... is specified and another where you enter the text, but this could become very confusing for the end user and that is not what I want!
Any ideas?
Thanks,
Adam
-
Feb 3rd, 2002, 12:14 PM
#2
Member
Hi,
Did you try the following:
<form......onSubmit="return someFunc()">
<input type='hidden' name='rtfText'>
....
<input type='submit'...>
</form>
function someFunc()
{
....validation code, if necessary....
document.formname.rtfText.value = FULLDOM.idContent.document.body.innerHTML
}
note: if you only want to send the rtfText, you should be able to send it via:
action='somepage.asp?someVar= document.formname.rtfText.value'
Vinny
-
Feb 3rd, 2002, 12:32 PM
#3
Thread Starter
Addicted Member
Thanks for the code Vincent, but unfortunately, it didn't work. Here is what I tried:
PHP Code:
function Save()
{
document.formname.rtfText.value = FULLDOM.idContent.document.body.innerHTML
}
then...
PHP Code:
<form method="post" action="dada.asp" onSubmit="return Save()">
<input type="text" name="test" value="wassup">
<input type='hidden' name='rtfText'>
<input type="submit" name=submit value=submit>
<form>
(I know I shouldn't have used [php] but I felt it was the best way to seperate them!)
The "test" value works and is sent, but the RTF is not. Any ideas?
Thanks,
Adam
-
Feb 3rd, 2002, 12:37 PM
#4
Member
Hi,
where I put 'FULLDOM', I meant for you to insert the 'full DOM', if it wasn't already in 'idContent.document.body.innerHTML'
that is, what is 'idContent'? 'document.all', 'document.getElementByID' ?
or something else?
Vinny
-
Feb 3rd, 2002, 12:43 PM
#5
Thread Starter
Addicted Member
I believe it is already stated, but I'm not sure - sorry. (I'm not that used to JavaScript)
-
Feb 3rd, 2002, 12:46 PM
#6
Thread Starter
Addicted Member
Got it sorted now - thanks... it wasn't your code that was wrong, it was my lack of understanding of JS - it works now.
Adam
-
Feb 3rd, 2002, 01:08 PM
#7
Member
Hi Adam,
Glad to have been of help. If you need to up your javascript, go through the tutorial at: www.htmlgoodies.com It may old, but it is still useful -- should take you about an hour or two (depends how fast you read 
Vinny
-
Feb 3rd, 2002, 01:11 PM
#8
Thread Starter
Addicted Member
I think I might do - I'll always use ASP for most stuff, but JavaScript is a bit easier for certain things... popups etc...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|