JavaScript - Emailing From User Provided Address
I'm trying to make a similar form to what Craigslist uses where you can mail to a user provided email and make it look like it came from whatever email address the user provides. I've looked at the code from the Craigslist page and can't seem to find the correct program they are using.
I've been out of the game for a while and saying my coding is rusty is an understatement. Any help would be appreciated. Similar TutorialsCode: var ip = '<!--#echo var="REMOTE_ADDR"-->'; xmlhttp.open("GET","getuser.php?q="+str+"&ip="+ip,true); xmlhttp.send(); I'm sending the above via a GET to a php file that inserts into a DB. here is the php portion Code: <?php $q=$_GET["q"]; $ip=$_GET["ip"]; $sql="INSERT INTO statcounter (selection, ip) VALUES ('".$q."','".$ip."')"; It is inserting properly into the DB, but the IP isn't correct. In the IP field I'm getting "<!--" instead of the users IP address. Would anyone have any advice on this? I took the first line from this website http://javascriptsource.com/user-det...p-address.html Apparently they were able to get the IP from only using var ip = '<!--#echo var="REMOTE_ADDR"-->'; But I'm not sure how they were able to do this EDIT: I SOLVED THIS BY USING "#" instead of "?". Thank you. Hello. My goal is to take a user's email from a form, store it in a cookie, and append it to the window location on the following page. I am doing this so that when a user shares the page with "add this widget" the stats will show me who shared the page. The problem I have is that window.location.replace("?"+ user_email); seems to be sending the browser in an infinite loop. Right now it is running as an inline function in the head. I tried calling the function with body onload and had the same problem. Code: <script = "Javascript"> (function readCookie() { var user_email = unescape(document.cookie); if (document.cookie) { window.location.replace("?"+user_email); } })(); </script> Is there another way I could achieve the same result? Thank you, Jack Hey all, I want to be able to update the line chart of google visualizations. Here is my code in question: http://jsfiddle.net/YCqyG/5/ Click the button called "click" and suddenly chart disappears. thanks for response I am still learning HTML, JavaScript and web design, so be patient with and reply in details. I want to be able to send data store in JavaScript variable to my email account. I have tried using mailto: command and for some reason it doesn't work. C Can someone please show me how to in details. I wrote quiz using HTML and JavaScrip. Score is accumulated in a variable called myScore. Now I want to email the result of myScore to an email address. How do I go about doing this? I don't want to use the mailto: command since that require that user actually press the send command to send the email. I want this done automatically after user finishes the quiz. Please explain all replied in details since I am new to JavaScript and still learning. I know almost nothing about javascript, but the guy who used to handle my company's forms has moved on and I need to edit one. Specifically, the form has a field for a district number, and I need to set it up so that if a certain district number is entered, the form submission gets emailed to a specified email address. I'm not trying to make it an email-only form - the results have to be posted in an output file as well. I've tried googling for an answer but haven't found anything that answers my question. Maybe that's because I don't know enough javascript to understand the answers. Can anyone help?? Thanks! I've not done anything with JavaScript before, so I'm not sure what syntax error I'm committing. I have a form made in Acrobat 9 for the Mac, and on it there is a "submit via email" button. I want the resulting email, which will contain the filled out Acrobat form as an attachment, to use field from the form to populate the subject line and the CC address field. I've bodgered together some code from this Acrobat user's post, but in trying to customize it, my script has fallen apart. I think it should be a simple fix, but since I'm so new, I can't see it. My script so far is: Code: // This is the form return e-mail. Its hardcoded // so that the form is always returned to the same address // Change address on your form var cToAddr = "fogharty@xxx.xxx"; // First, get the client CC e-mail address var cCCAddr = this.getField("Teacheremail").value; // Set the subject and body text for the e-mail message var cSubLine = "this.getField("CourseNumber").value; + "corrections form submitted by " + + this.getField("TeacherName").value; var cBody = "\n Thank you for submitting your form.\n" + "Save the mail attachment for your own records"; // Send the form data as an PDF attachment on an e-mail this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine, cMsg: cBody}); So I would like the subject line to read (CourseNumber) corrections form submitted by (TeacherName) Acrobat tells me I have a "SyntaxError: missing ; before statement 11: at line 12" but no matter how I tweak it, I keep getting that message. I put the semi-colon in, I take the semi-colon out, I put the semi-colon back in and shake it all about.... nothing. Any help someone could give me will be greatly appreciated, thanks Oh, and would there be a way to have the sent pdf form have it's name from a couple of fields as well? So that the attached file will be called "(CourseNumber).pdf"? hello everybody how can I set url in the address without opening the url , just placing ??? i.e : to open a url we use this PHP Code: document.location = 'http://www.codingforums.com/' I wanna show the user that the url is changing in the address bar as typing after it reached the end it will opens the url I don't care for the method of writing the new url in the address bar such as typing or sliding ... etc please tell me how to do this thanks I want to know how can i make javascript that i can use by run into in address bar.. I just need such javascript that run through address bar. My purpose is How can i check all check box in webpage that do not include all check or uncheck button? Best common example for check all or uncheck all is Quote: <html> <head> <title>Check All</title> <SCRIPT LANGUAGE="JavaScript"> function checkall(formid) { len=formid.ckb.length for(i=0;i<len;i++) { formid.elements.ckb[i].checked=true } } function uncheckall(formid) { len=formid.ckb.length for(i=0;i<len;i++) { formid.elements.ckb[i].checked=false } } </SCRIPT> </head> <body> <CENTER> <FORM NAME="myform"> <INPUT TYPE="checkbox" NAME="ckb"> Checkbox One <BR> <INPUT TYPE="checkbox" NAME="ckb"> Checkbox Two <BR> <INPUT TYPE="checkbox" NAME="ckb"> Checkbox Three <BR> <INPUT TYPE="button" NAME="chka" VALUE="Check All" onClick="checkall(this.form)"> <INPUT TYPE="button" NAME="unchka" VALUE="Uncheck All" onClick="uncheckall(this.form)"> </FORM> </CENTER> </body> </html> Now for above code If there would not have any javascript for select all then how can i use the select all javascript that i can run through address bar. i.e how can i just check all check box by using javascript? Hi guys! I have tried numerous attempts in getting the Address field to work (i.e. validated). I want it to accept letters, numbers, spaces and commas! However, it won't let me! Below is the code I have provided. Code: function validateAddress(fld) { var error = ""; var illegalChars = /[\W_]/; // } else if (illegalChars.test(fld.value)) { fld.style.background = 'Yellow'; error = "Your Billing address contains illegal characters!\n"; } else { fld.style.background = 'White'; } return error; } Thanks a lot! I apologise if this is in the wrong section. I have built a website using iframes at: http://www.krillmeed.com/ but when clicking through the menu, the address bar still stays at http://www.krillmeed.com/ no matter which page is loaded into the iframe. I have seen a number of javascripts around that can change this, but most do not seem to work anymore. Has anyone a sure way to correct this please
The below code works ok but need our help to get it perfect. I want the function to validate that after the "@" the user types "wendys.com". Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>New Page 1</title> <SCRIPT> function validateLP(theForm){ if(theForm.DM_Email){ var checkEmail =theForm.DM_Email.value; var invalidChars = " /:,;" if (checkEmail == "") { alert("Please enter a valid Wendys DM email address."); theForm.DM_Email.style.backgroundColor='#FFFF99'; theForm.DM_Email.focus(); return false; } if (checkEmail != "") { // can be empty for (i=0; i<invalidChars.length; i++) { // does it contain any invalid characters? var badChar = invalidChars.charAt(i) if (checkEmail.indexOf(badChar,0) > -1) { alert("Please enter a valid Wendys DM email address."); theForm.DM_Email.style.backgroundColor='#FFFF99'; theForm.DM_Email.focus(); return false; } } var periodPos1 =checkEmail.indexOf(".",1) // there must be one "." symbol var atPos = checkEmail.indexOf("@",periodPos1-1) // there must be one "." symbol before "@" var periodPos2 = checkEmail.indexOf(".",atPos) //periodPos2 = checkEmail.indexOf(".",atPos) if ( (atPos == -1) || (periodPos2 == -1)){ //return false alert("Please enter a valid Wendys DM email address."); theForm.DM_Email.style.backgroundColor='#FFFF99'; theForm.DM_Email.focus(); return false; } } } } </SCRIPT> </head> <body> <form method="POST" NAME="theForm" onSubmit="return validateLP(theForm)" action="--WEBBOT-SELF--"> <p><input type="text" name="DM_Email" size="20"></p> <p> </p> <p> </p> <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> </form> </body> </html> Hi there, i really could use the help. Ok, so (and im sure i will be told other ways) i have come up with a way of blocking people from my site even if they are currently on the site and dont reload the page. What i was thinking of is simply: a tiny iframe on the bottom of my page, so small it cant be seen ie 1px that iframe goes to a page saying YOU HAVE BEEN BANNED That page istself will be on a constant 10 seccond refresh so as soon as i add the ip address to it, BOOM, it will break out of the iframe and take the user away from the main page as display the you have been banned message. Sound good? ok, so here is what i have sofar but i know its wrong, dont really know how to write it correctly. The main point is: if ip is 111.111.111 then break out of iframe else do nothing. Thanks for the help. Code: <script language="JavaScript"> VIH_ForeColor = "navy"; VIH_FontPix = "16"; VIH_DisplayFormat = "%%IP%%"; VIH_DisplayOnPage = "no"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> <script> if (VIH_HostIP == "111.111.111.111") document.write('if (top.location!= self.location) { top.location = self.location.href }' ); }else{ document.write(''); ;} </script> hi, how can i get client mac address OR hdd id with javascript for internet explorer? I am trying to make an addition to a .js plugin for a wiki. Currently it does not support sorting my IP address. So far I have created the below code which does more than the script initially did, but is still not sorting 100% correctly. Any tips? Code: sort_ipaddr: function(a,b){ aa = a[0].split(".",4); bb = b[0].split(".",4); var counti = 0; for (var i=0; i<4; i++) { if (parseInt(parseFloat(aa[i])) == parseInt(parseFloat(bb[i]))){} if (parseInt(parseFloat(aa[i])) < parseInt(parseFloat(bb[i]))){counti--} if (parseInt(parseFloat(aa[i])) > parseInt(parseFloat(bb[i]))){counti++} } return counti; }, EDIT I've also tried this which is closer but still not there. Code: sort_ipaddr: function(a,b){ aa = a[0].split(".",4); bb = b[0].split(".",4); var resulta = (aa[3]+(aa[2]*256)+(aa[1]*256*256)+(aa[0]*256*256*256)); var resultb = (bb[3]+(bb[2]*256)+(bb[1]*256*256)+(bb[0]*256*256*256)); return resulta-resultb; }, This results in a list like so: 10.1.15.22 10.1.16.22 10.1.15.23 10.1.15.24 10.1.16.24 10.1.15.25 Hi. I'm using the following script to allow a user to automatically fill some fields based on their previous entries. It works in FF, but doesn't work in IE. I'm not a js genie so hopefully one of you can help me out here. Thanks. js: Code: function shipsame(form){ if(form.sameasbilling.checked){ form.firstnameb.value = form.firstname.value; form.lastnameb.value = form.lastname.value; form.address1b.value = form.address1.value; form.address2b.value = form.address2.value; form.towncityb.value = form.towncity.value; form.stateb.value = form.state.value; form.zipcodeb.value = form.zipcode.value; }else{ form.firstnameb.value = ""; form.lastnameb.value = ""; form.address1b.value = ""; form.address2b.value = ""; form.towncityb.value = ""; form.stateb.value = ""; form.zipcodeb.value = ""; } } html: Code: <legend>Billing Address</legend> <ol> <li style="line-height:300%;"> <input type="checkbox" name="sameasbilling" value="yes" onClick="shipsame(this.form);"><span> Same as Shipping Address</span> </li> <li> <label for="firstnameb">First Name</label> <input id="firstnameb" name="firstnameb" value="<?php echo $cart->p_fnameb(); ?>" /> <script type="text/javascript"> var firstnameb = new LiveValidation('firstnameb'); firstnameb.add(Validate.Presence); </script> </li> Hi there, i really could use the help. Ok, so (and im sure i will be told other ways) i have come up with a way of blocking people from my site even if they are currently on the site and dont reload the page. What i was thinking of is simply: a tiny iframe on the bottom of my page, so small it cant be seen ie 1px that iframe goes to a page saying YOU HAVE BEEN BANNED That page istself will be on a constant 10 seccond refresh so as soon as i add the ip address to it, BOOM, it will break out of the iframe and take the user away from the main page as display the you have been banned message. Sound good? ok, so here is what i have sofar but i know its wrong, dont really know how to write it correctly. The main point is: if ip is 111.111.111 then break out of iframe else do nothing. Thanks for the help. Code: <script language="JavaScript"> VIH_ForeColor = "navy"; VIH_FontPix = "16"; VIH_DisplayFormat = "%%IP%%"; VIH_DisplayOnPage = "no"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> <script> if (VIH_HostIP == "111.111.111.111") document.write('if (top.location!= self.location) { top.location = self.location.href }' ); }else{ document.write(''); ;} </script> I have this script to validate contact form fields. It works fine for checking that fields are not blank. I added the valid email code, which I copied from the w3schools web site. But, it does not work. I am confused about how to reference the email form field name. That is really the only thing I changed, that is, I added the frm.elements to the email variable. Can anyone please help? Thanks! Code: function validate_form(frm) { frm.elements.name.className = "input"; frm.elements.email.className = "input"; frm.elements.subject.className = "input"; frm.elements.comments.className = "input"; var errors=0; // // NAME cannot be blanks // if (isBlank(frm.elements.name.value)) { frm.elements.name.className = "inputreq"; errors++; } // // EMAIL ADDRESS cannot be blanks // if (isBlank(frm.elements.email.value)) { frm.elements.email.className = "inputreq"; errors++; } // // SUBJECT cannot be blanks // if (isBlank(frm.elements.subject.value)) { frm.elements.subject.className = "inputreq"; errors++; } // // COMMENTS cannot be blanks // if (isBlank(frm.elements.comments.value)) { frm.elements.comments.className = "inputreq"; errors++; } // // EMAIL ADDRESS appears invalid // if (validate_email(frm.elements.email.value,"Not a valid e-mail address!")==false) { alert("TEST"); frm.elements.email.focus(); return false; } // // Errors // if (errors>0) { alert("Please enter all fields!"); return false; } //No errors //frm.submit(); } function isBlank(value) { regexp = /^\s*$/ return (value==null || regexp.test(value)); } // Validate email address function validate_email(field,alerttxt) { with (field) { apos=value.indexOf("@"); dotpos=value.lastIndexOf("."); if (apos<1||dotpos-apos<2) {alert(alerttxt);return false;} else {return true;} } } Hello. Is the any chance to increment IP address in Javascript ? For example 11.12.13.14 plus 1 will be 11.12.13.15 I've started to modify my old script: Code: var ipa = 10.11.12.13; var partsa = []; var tempa = ipa; for ( var p = 0; p < 3; ++p ) { var dot1t = tempa.indexOf("."); partsa[p] = tempa.substring(0,dot1t); tempa = tempa.substring(dot1t+1); } partsa[3] = tempa; But do not know how to display ip like: ( parts1[0].parts1[1].parts1[2].parts1[3]+1 ) Please help. Leos When redirecting a new window, the window should not contain a address bar or the url input text bar. How this can be done. |