Results 1 to 8 of 8

Thread: JavaScript & Form Posting

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    181

    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

  2. #2
    Member Vincent Puglia's Avatar
    Join Date
    Feb 2002
    Location
    where the World once stood
    Posts
    36
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    181
    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

  4. #4
    Member Vincent Puglia's Avatar
    Join Date
    Feb 2002
    Location
    where the World once stood
    Posts
    36
    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

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    181
    I believe it is already stated, but I'm not sure - sorry. (I'm not that used to JavaScript)

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    181
    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

  7. #7
    Member Vincent Puglia's Avatar
    Join Date
    Feb 2002
    Location
    where the World once stood
    Posts
    36
    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

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    181
    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
  •  



Click Here to Expand Forum to Full Width