1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

form & javascript in Wordpress post not working

Discussion in 'WordPress' started by lukeprog, Sep 7, 2007.

  1. #1
    I have included some JavaScript and a form in my WordPress blog post. The whole thing works great when it's a standalone HTML page, but when I make it a WordPress post the "Highlight" (submit) button doesn't work.

    I suppose the WordPress formatting or markup is breaking things. But I use the text control plugin and my form still doesn't work even when I remove formatting and character encoding.

    How can I get my "Highlight" button to work?

    Below is the working HTML file, followed by the Wordpress blog code (the only difference is that the Wordpress code lacks tags like:
    <html> <head> </head> <body> </body> </html>
    Code (markup):
    )

    Here's the HTML file, try it for yourself:

    http://wordpress.pastebin.ca./684541

    And here's the non-working WordPress code:

    http://wordpress.pastebin.ca./684542

    Any ideas?
     
    lukeprog, Sep 7, 2007 IP
  2. sat123

    sat123 Banned

    Messages:
    1,600
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #2
    in wordpress find header.php (header) of your theme in themes->theme editor
    and put the javascript and stylesheet part of http://wordpress.pastebin.ca./684542 there with in head

    But codes bellow needs to be in the post it self.... either use code view of post editor or just add the code to single.php of your template (edit in themes->theme editor)

    #
    <h3>Usage Notes</h3>
    #
    Paste your text into the textbox and click <i>Highlight</i>. Certain words and phrases are highlighted.
    #
     
    #
    <form>
    #
    <textarea id=TA rows=10 cols=50 >Paste your text to here. Phrase list.</textarea><br />
    #
    <input type="button" name="" value="Highlight" onclick="zxcHiLight('TA','Para2',HiliteAry,'hlite');document.getElementById('Para2').style.height='100px';document.getElementById('Para2').style.padding='5px';"/>
    #
    <div id="Para2" style="overflow:auto;width:500px;height:0px;background-Color:#FFFFCC;border:solid black 0px;" >
    #
    </div>
    #
    </form>
    HTML:
    Because javascript functions should be in header ...if that html does not fit in post u add to template by editing single.php of your template
     
    sat123, Sep 8, 2007 IP
    darkmessiah likes this.
  3. darkmessiah

    darkmessiah Peon

    Messages:
    500
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I know this is a couple months old, but this really is good info. I was testing some onclick stuff in wordpress and moving the script to the header did the trick. Oddly it worked fine on the index page, but failed to work on the interior pages before. Everything is perfect know.
     
    darkmessiah, Dec 9, 2007 IP
  4. shoaeeb

    shoaeeb Peon

    Messages:
    165
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You did not mentioned in which language you have written form code?
     
    shoaeeb, Dec 9, 2007 IP