Hi
I am using the following newsletter script
http://www.plus2net.com/php_tutorial/newsletter.php
It all works fine apart from I don't seem to be getting a confirmation message when I click submit?
below is my script
Hope someone can help, thank you in advanceCode:<form name='myForm' action='' method='post'> <table class='t1'> <input type=hidden name=todo value='post-data'> <tr class='r1'> <td> <label>Email Address</label> <br /> <input type=text name='email' size=40> </td> </tr> <tr class='r0'> <td> <label for="number" class="title">What is three plus four?</label> <input name="number" id="number" required="required" pattern="7" title="Please answer the question to prove you are human"> </td> </tr> <tr class='r0'> <td> <input type="button" onClick="ajaxFunction()" value='Signup'> </td> </tr> </table> </form> </div> </div> <script type="text/javascript"> function ajaxFunction() { var httpxml; try { // Firefox, Opera 8.0+, Safari httpxml=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { httpxml=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpxml=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } function stateChanged() { if(httpxml.readyState==4) { /////////////////////// //alert(httpxml.responseText); var myObject = JSON.parse(httpxml.responseText); //alert(myObject.data[0].msg); if(myObject.data[0].status_form==="NOTOK"){ // status of form if notok document.getElementById("msgDsp").style.borderColor='red'; document.getElementById("msgDsp").style.background='#f0f0c0'; document.getElementById("msgDsp").innerHTML=myObject.data[0].msg; }/// end of if if form status is notok else { ///// Validation is passed document.getElementById("msgDsp").style.borderColor='blue'; document.getElementById("msgDsp").style.background='#2CFC90'; document.getElementById("msgDsp").innerHTML=" Thank You <br> Please Check your email to confirm subscription .... <br>"; document.myForm.reset(); } // end of if else if status form notok /////// Changing the border colors ///////////// ////////////// } } ///////////////////////////////// function getFormData(myForm) { var myParameters = new Array(); myParameters.push("todo=" + myForm.todo.value); myParameters.push("email=" + myForm.email.value); return myParameters.join("&"); } //////////////////////////////////////////// var url="subscribeck.php"; var myForm = document.forms[0]; var parameters=getFormData(myForm); httpxml.onreadystatechange=stateChanged; httpxml.open("POST", url, true) httpxml.setRequestHeader("Content-type", "application/x-www-form-urlencoded") //alert(parameters); httpxml.send(parameters) document.getElementById("msgDsp").innerHTML="<img src=wait.gif>"; //////////////////////////////// } </script>
Ian



Reply With Quote

Bookmarks