So I have my form all set up... I really like how it looks.
I have the subscribe form up on my website (
http://www.vanilla-chai.nu) and I'm trying to add dummy users. But when I hit the 'Subscribe' button, you just get taken to the default subscribe page asking to enter your email.... I don't want this. I want the user to be brought to the default 'thank you' page. I had this working earlier, but I don't know what's wrong with it now.
EDIT: Upon further investigation, I've come to realize that when I use the standard submit button, everything works perfectly. But if I change the submit button to an image, the form doesn't submit like I want it to. Does anybody know why this is?
FIXED: So I figured I would post this here in case it might help somebody else out there.
I've been searching the net for hours on how to fix this issue, all to no avail. That is, until I came upon a very simple workaround using CSS. To be able to use an image AND have the form submit properly I added the following code to my input:
- Code: Select all
style="background: url(http://www.vanilla-chai.nu/img/subscribe.png); width: 205px; height: 75px; border: 0px;"
I left the input type as
type="submit" and passed along a blank value (
value=""), and it works perfectly. The only caveat I could find was, when somebody hovers their mouse over the submit image, and even clicks, the cursor remains an arrow. I tried adding
cursor: hand; to my inline style, but it didn't. I'm sue there is a way to do that- but I don't feel like fussing with that right now. I'm just glad I have it working the way I want. I don't think the style of the cursor is really a huge deal anyway.
This is what my form looks like:
- Code: Select all
<script language="Javascript" type="text/javascript">
function checkform() {
for (i=0;i<fieldstocheck.length;i++) {
if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].type") == "checkbox") {
if (document.subscribeform.elements[fieldstocheck[i]].checked) {
} else {
alert("Please enter your "+fieldnames[i]);
eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
return false;
}
}
else {
if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
alert("Please enter your "+fieldnames[i]);
eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
return false;
}
}
}
for (i=0;i<groupstocheck.length;i++) {
if (!checkGroup(groupstocheck[i],groupnames[i])) {
return false;
}
}
return true;
}
var fieldstocheck = new Array();
var fieldnames = new Array();
function addFieldToCheck(value,name) {
fieldstocheck[fieldstocheck.length] = value;
fieldnames[fieldnames.length] = name;
}
var groupstocheck = new Array();
var groupnames = new Array();
function addGroupToCheck(value,name) {
groupstocheck[groupstocheck.length] = value;
groupnames[groupnames.length] = name;
}
function compareEmail() {
return (document.subscribeform.elements["email"].value == document.subscribeform.elements["emailconfirm"].value);
}
function checkGroup(name,value) {
option = -1;
for (i=0;i<document.subscribeform.elements[name].length;i++) {
if (document.subscribeform.elements[name][i].checked) {
option = i;
}
}
if (option == -1) {
alert ("Please enter your "+value);
return false;
}
return true;
}
</script>
<form action="http://www.vanilla-chai.nu/lists/?p=subscribe" method="post" name="subscribeform">
<input type="hidden" name="formtoken" value="c8f9f2b0f152b05322267bff0ba0971d" />
<table border=0 cellpadding="0" cellspacing="0">
<tr>
<td class="attributeinput">
<center>
<span class="required">
Name: <input type="text" name="name" value="" size="21">
<br />
Email: <input type=text name=email value="" size="22">
</span>
</center>
<script language="Javascript" type="text/javascript">addFieldToCheck("name","Name,"email","Email");</script>
</td>
</tr>
<tr>
<td colspan="2">
<input type="image" src="http://www.vanilla-chai.nu/img/subscribe.png" name="subscribe" value="" onClick="return checkform();">
<input type="hidden" name="htmlemail" value="1">
<input type="hidden" name="list[1]" value="signup">
<input type="hidden" name="listname[1]" value="test"/>
<div style="display:none"><input type="text" name="VerificationCodeX" value="" size="10"></div>
</p>
</td>
</tr>
</table>
</form>