Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem creating form in javascript

    Hi,

    I am hoping that someone here might be able to help me with a problem that I am having with a website that I am working on.

    The site is based with Wild Apricot, which means I am not creating the pages from scratch, they are based on templates. I do not have access to edit the full source code, however, they do allow me to add HTML directly.

    The problem that I am having is that I wish to add a mailing list subscription box to the website. I am planning to use an external provider, called Your Mailing List Provider, that provides me with a snippet of HTML code to put on my website. This is the snippet (I have replaced the URL with "URL", just for privacy):

    Code:
    <form method=post action=URL>
    <table border=0>
    <tr>
    <td colspan=2>Fill out your e-mail address<br>to receive our newsletter!</td>
    </tr>
    <tr>
    <td><input type=text name=YMLP0 size=20></td>
    <td><input type=submit value="Submit"></td>
    </tr>
    </table>
    <input type=hidden name=email_only value=1>
    </form>
    Unfortunately, what I've found is that Wild Apricot does not allow me to paste a form into their website. Their editor seems to just parse it out and remove it. They have a knowledgebase article about this, which explains that this is necessary "because there is already a WA-generated FORM around the whole page content and HTML standards do not allow to place one form into another one." (Full article is here and I am trying solution #2 as solution #1 will not work for me: http://help.wildapricot.com/display/...ing+HTML+forms)

    The Wild Apricot knowledgebase describes this as a solution to the problem:

    The workaround is quite straight forward - you need to place javascript code to your submit button which changes the form.action to the one you need:

    <input
    type="submit"
    ...
    onclick="document.forms[0].action='<form_processing_url>'"
    ...
    />where <your url> is the url where your form has to be posted.


    Frankly, I have not used javascript before and am having trouble getting this to work. This is what I have written so far (again I replaced the subscription posting URL with "URL"):

    Code:
    <INPUT name=YMLPO> <INPUT
    onclick="document.forms[0].action='URL'"
    type=submit value=Subscribe ...>
    It seems that with this, it does contact the correct website, but it doesn't seem to be passing the name inputted into the text box along correctly. Could anyone advise me on how to make this work?

    thanks,
    Rachel

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,142
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    This should work:-

    <td><input type= "text" name = "YMLP0" size = "20"></td>
    <td><input type = "submit" value = "Submit" onclick = "document.forms[0].action = 'URL' "></td>


    "He rubbed a few noses up the wrong way ....." - Sports commentator

  • #3
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much!! That worked.

    Can you believe it, neither the Wild Apricot or YMLP customer service teams could/would help me with this. (Could for YMLP, would for Wild Apricot.)

    Thank goodness for the programming community!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •