Hi I wish to do the following with a single form: the customer can send a message using the contact form, and if he checks a checkbox, than he will be subscribed to our newsletter using SM2 Marketing.
For this I have created this form:
If boletin=1 then I would like to run the following javacode
I believe I would have to remove the form stuff and only leave the javascript to be executed, but not sure how to go around it. Unfortunately I do not know any javascript if I have to make changes in the code. Any help appreciated.
For this I have created this form:
<div class="form_sx"> Nombre:<strong> (*)</strong><br /> <input name="name" type="text" class="text" size="30" id="nombre" /> <br /> E-mail:<strong> (*)</strong><br /> <input name="email" type="text" class="text" size="30" id="email" /> <br /> Asunto:<br /> <select name="subject" class="text" id="asunto"> <option value="requiero mayor información">requiero mayor información</option> <option value="favor cotizar proyecto">favor cotizar proyecto</option> <option value="interesado en instalar">interesado en instalar</option> <option value="otro">otro</option> </select> <br /> </div> <div class="form_dx"> Teléfono/celular:<strong> (*)</strong><br /> <input name="telefono" type="text" class="text" size="30" id="telefono" /> <br /> Ciudad:<strong> (*)</strong><br /> <input name="ciudad" type="text" class="text" size="30" id="ciudad" /> </div> <div style="clear:both; padding-left:20px; padding-right:20px"> Texto:<br /> <textarea name="message" cols="" rows="" class="textarea" id="mensaje"></textarea> <br /> <input name="boletin" type="checkbox" id="boletin" value="1" checked="checked" /> Deseo recibir en forma gratuita el boletÃn mensual de noticias .<br /> <input type="submit" class="puls_form" value="Enviar" /> <input type="reset" value="Cancelar" class="puls_form" /> <br /> <br /> <strong>(*)</strong> Campos obligatorios. </div>
If boletin=1 then I would like to run the following javacode
<jos:comment> @package Joomla! @subpackage com_sm2emailmarketing @copyright Copyright (C) 2006 SM2 / All Rights Reserved @license commercial @author SM2 <info@sm2joomla.com> </jos:comment> <jos:tmpl name="subscriber"> <script language="javascript" type="text/javascript"> function submitSM2EMSubscription() { var coll = document.sm2EMSubscribe; var r = new RegExp("[^0-9A-Za-z]", "i"«»); var errorMSG = ''; var iserror=0; if (coll != null) { var elements = coll.elements; // loop through all input elements in form for (var i=0; i < elements.length; i++) { // check if element is mandatory; here mosReq=1 if (elements.item(i).className.indexOf('required') != -1) { // check for empty field value if (elements.item(i).value == '') { // add up all error messages errorMSG += elements.item(i).getAttribute('title') + '\n'; // notify user by changing background color, in this case to red elements.item(i).style.backgroundColor = "#CC0000"; iserror=1; continue; } } } } if(iserror==1) { alert('{ERROR}\n'+errorMSG); return false; } else { return true; } } </script> <form action="<jos:«»sef>index.php?option=com_sm2emailmarketing&task=subscribe</jos:«»sef>" method="post" name="sm2EMSubscribe" id="sm2EMSubscribe" onsubmit="return submitSM2EMSubscription()"> <jos:tmpl type="simplecondition" requiredvars="display_details" varscope="subscriber"> <br /><br /> <label> <span>{NAME}: </span><br /> <input type="text" name="name" class="inputbox required" title="{ERRNAME}" size="17"/><br /> </label> <label> <span>{EMAIL}: </span><br /> <input type="text" name="email" class="inputbox required" title="{ERREMAIL}" size="17"/><br /> </label> </jos:tmpl> <!-- Enter the 1 for HTML or 0 for text t o enable the auto setting of HTML or TEXT subscriptions. --> <input type="hidden" name="html" value="1" /> <!-- --> <label> <span>{ACTION}: </span><br /> <select name="status"> <option value="1">{SUBSCRIBE}</option> <option value="0">{UNSUBSCRIBE}</option> </select> </label> <jos:tmpl type="simplecondition" requiredvars="display_lists" varscope="subscriber"> <!-- Enter the ID of the list to be auto subscribed in the value field below. If you wish to be auto subscribed to multiple lists then copy the following hidden field for each list. --> <input type="hidden" name="lists[]" value="1" /> </jos:tmpl> <br /> <input type="submit" value="{SUBMIT}" class="button" /> </form> </jos:tmpl>
I believe I would have to remove the form stuff and only leave the javascript to be executed, but not sure how to go around it. Unfortunately I do not know any javascript if I have to make changes in the code. Any help appreciated.