View Full Version : Problem creating form in javascript

09-04-2008, 10:57 PM

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

<form method=post action=URL>
<table border=0>
<td colspan=2>Fill out your e-mail address<br>to receive our newsletter!</td>
<td><input type=text name=YMLP0 size=20></td>
<td><input type=submit value="Submit"></td>
<input type=hidden name=email_only value=1>

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/DOC/Inserting+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:

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

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?


Philip M
09-05-2008, 08:58 AM
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

09-05-2008, 03:56 PM
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!