Sending an email from HTML [duplicate] - html

This question already has answers here:
Can I set subject/content of email using mailto:?
(13 answers)
Closed 7 years ago.
<form action="MAILTO:myemail#example.com" method="post" enctype="text/plain">
<input type="text" value="Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name';}" required="">
<input type="text" value="E-mail" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'E-mail';}" required="">
<textarea type="text" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message';}" required="">Message</textarea>
<input type="submit" value="SEND">
</form>
The code above is in my HTML file. Once I write text in the textboxes and click the submit button it opens a new email using my email client (So far so good). But, there is not any content in the body of the email. I want to have the text I inputted to be in the body of the new email which just opened. I do not want to use any PHP or JavaScript files. I want everything to be in the HTML file.
Thanks!

Add name=body to your text area
<textarea name='body' ... ></textarea>
Each of the other inputs can be assigned to the different lines of the email message (ie, the subject line, to line, cc, etc). All you need to do is set the "name" property of each input to the line of the email you want it to appear.
If you want your name input to be the subject of the message, add `name='subject' to your name input.
https://en.wikipedia.org/wiki/Mailto
Also, you should probably change the method to 'GET' and enforce a URI encode before the data is sent using encodeURI(value of the textarea)

Related

Why won't this code display on a wordpress page?

This code displays as plain text on any pages I put it on. It is supposed to display two text boxes and two buttons
<div onmouseover="change_background(this, '#FCF6CF')" onmouseout="change_background(this,'#E8E8E8')" id="client_portal_content">
Client Login
<INPUT id=logintext size="15" onblur="if (this.value == '')
this.value='Your client ID'" onfocus="this.value=''" value="Your client
ID"></INPUT>
<INPUT id=loginbutton onclick="if
(document.getElementById('logintext').value != 'Your client ID')
window.open('http://1010.cmmcloud.com/progress/progress.php?id=p-'+document.getElementById('logintext').value)" type=button value=Login></INPUT>
<br><br> Affiliate Login
<INPUT id=logintextaff size="15" onblur="if
(this.value == '') this.value='Your affiliate ID'" onfocus="this.value=''" value="Your affiliate ID"></INPUT>
<INPUT id=loginbuttonaff onclick="if
(document.getElementById('logintextaff').value != 'Your affiliate ID')
window.open('http://1010.cmmcloud.com/affportal/portal.php?id=a-'+document.getElementById('logintextaff').value)" type=button value=Login></INPUT>
</div>
You have errors in your code, which doesn't explain why it appears as plain text, but would explain why it won't run in any case. Instead of using a function 'onblur' to fill the text and then check if it's filled on submit, use placeholder text, and then check if the input is empty.
See below example:
function check() {
var x = document.getElementById("#myid");
if (x == null|| x=="") {
alert("Fill in your id!");
}
}
<input id="myid" type="text" placeholder="Client ID" />
<button onclick="check();">Click me</button>
Hope this helps
EDIT:
In your tag (which doesn't need to be capitalised, by-the-by), you have
onclick="if
(document.getElementById('logintext').value != 'Your client ID'
Replace with
onclick="if
(document.getElementById('logintext').value != null )
<input id="logintext" size="15" placeholder ="Your Client ID"
value=" "></input>

how to save form data in our computer that was filled by vister on our webpage

i want to know how to save data of the visitor that was filled by the visitor on our website
<ul class="form">
<li class="short">
<label>First Name<span class="required"></span></label>
<input type="text" name="first" id="first" value="First Name" class="requiredField" onblur="if(this.value == '') { this.value = 'First Name'; }" onfocus="if(this.value == 'First Name') { this.value = ''; }" />
</li>
You need to pass the data onto a program on your server. Usually you would use PHP, npm, python... but there are many options. It's not possible with only HTML or client side JavaScript alone unless you have them save the document and email it to you

Use text of text form for value of another?

I am fairly new to HTML and am having trouble figuring out this issue.
I have this form which lets the user enter their email address and then when they submit it registers them to the website.
I am wondering how can I get the value of the email address they enter for the value of another form?
Here's what I am working with. Any tips?:
<form class="form" method="post" action="https://register.sendreach.com/forms/?listid=7465"><input name="lid" value="7465" type="hidden">
<div class="field"><label>Email:</label>
<input class="text" name="email" value="My best email address is..." onblur="if (this.value == '') {this.value = 'My best email address is...';}" onfocus="if (this.value == 'My best email address is...') {this.value = '';}" type="text">
<form action="http://mywebsite.com/?mode=register&type=quick" method="post">
<input type="text" name="member_email" value = /></p> **<--- Here is where I want to get the email address text used earlier in the name field called email and use it for the name field member_email. I want to use that as the value. How do I grab that?**
<input name="product_id" value="1" type="hidden">
<input name="success_url" value="aHR0cDovL2luY29tZWphY2tlci5jb20vbWVtYmVyc2hpcC1ob21lLw==" type="hidden"></div>
<input class="button small_btn" value="Get Instant Access" type="submit">
<p class="small">Download Sent To Email!</p>
</form>
Do something on submit (similar to how you're doing something on focus and on blur):
<form onsubmit="...
On the submit event, get the two email inputs:
var sourceInput = document.getElementsByName('email')[0];
var targetInput = document.getElementsByName('member_email')[0];
...and set the value:
targetInput.value = sourceInput.value;
I didn't test the above, but I believe that should do what you're looking for. It may be better to give the two inputs ids as well, so you can use getElementById instead of getElementsByName.
Edit:
The above would only work if both inputs and forms are on the same page, and also if the page is not refreshed. Based on the question, I am assuming that's the case. The above also does not check to see if the email was saved successfully (again, I don't know if that's something you want to check before copying the email over).
use sessions
page one:
<?php
session_start();
$_SESSION['email_address']=$email_variable;
?>
page two:
<php
new_email_variable=$_SESSION['email_address'];
?>
use this.
<form class="form" method="post" action="https://register.sendreach.com/forms/?listid=7465"><input name="lid" value="7465" type="hidden">
<div class="field"><label>Email:</label>
<input class="text" name="email" value="My best email address is..." onblur="if (this.value == '') {this.value = 'My best email address is...';} document.getElementById('member_email').value=this.value;" onfocus="if (this.value == 'My best email address is...') {this.value = '';}" type="text">
<form action="http://mywebsite.com/?mode=register&type=quick" method="post">
<input type="text" name="member_email" id="member_email"></p> **<--- Here is where I want to get the email address text used earlier in the name field called email and use it for the name field member_email. I want to use that as the value. How do I grab that?**
<input name="product_id" value="1" type="hidden">
<input name="success_url" value="aHR0cDovL2luY29tZWphY2tlci5jb20vbWVtYmVyc2hpcC1ob21lLw==" type="hidden"></div>
<input class="button small_btn" value="Get Instant Access" type="submit">
<p class="small">Download Sent To Email!</p>
</form>
notice i have added id attribute to the input tage where you want to get the email address. and a little code in the tag from where you want to get the email address

Change to type password onblur

I try to do a form with the information in the same input. It works fine in all the inputs but in the password it would be better if it could change to points when the user introduces the password. I want it to be type text and change to type password ONLY when the user introduces the password. The problem is in the last line of code:
I have it life here: http://jsfiddle.net/Nt9gx/
<form>
<input type="text" name="name" value="name"
onfocus="if (this.value=='name') this.value = '';"
onblur="if (this.value=='') this.value = 'name';"
/>
<input type="text" name="password" value="password"
onfocus="if (this.value=='password') this.value = '' type = password;"
onblur="if (this.value=='') this.value = 'password';"
"if (this.value!=''|| 'password') type = password ;"
/>
</form>
Use the HTML5 placeholder
To get the job done, you should simply use the HTML5 placeholder-attribute, like this:
<input type="password" name="password" placeholder="Password">
As this will:
show the placeholder, while no text is inserted or if all text is removed again
it shows the text even on a password field
no need using JavaScript
By the way:
you used two times onblur on the last input, this should occur only once
the last line is syntactically wrong, as you need to escape the word password in ' (single quotes) instead of " (double quotes) (question was updated)
the last line uses an undefined variable called password in || password)
use type="password" for input fields that handle, well, passwords, as the input will be "invisible"
Note:
If you still want to use JavaScript, you have to change the input from type="text" to type="password" within the focus and blur events by simply updating the type-attribute.
This is how you can do it:
<input type="text" name="password" value="password"
onfocus="if (this.value == 'password') { this.value = '', this.setAttribute('type','password'); }"
onblur="if (this.value == '') { this.value = 'password', this.setAttribute('type','text'); }"
>
Demo: http://jsfiddle.net/2Ps8N/​
<input type="text" name="name" value="name"
onfocus="if (this.value=='name') this.value = '';"
onblur="if (this.value=='') this.value = 'name';"
/>
<input type="password" name="password" value="password"
onfocus="if (this.value=='password') this.value = '';"
onblur="if (this.value=='') this.value = 'password';"
onblur="if (this.value!=''|| password) value = 'password';"
/>
you entered a double quote!
You can change the password input like this :
<input type="text" name="password" value="password" type="password"
onfocus="if (this.value=='password') this.value = '';"
onblur="if (this.value=='') this.value = 'password';"
/>
Yoc can add more conditions in if (this.value=='') but do it just in this onblur and do not write another onblur
You have this.value = "password" in the last line which is wrong and you must use 'password' instead of "password"
in the last if condition you have the parameter password that is not defined before using it. you should define var password before this if or you should change this condition

input field has initial values that browser remembers but i dont want them to appear

I have two things i want to do to this input text field.
<input type="text" value="email#abc.com" name="Email" id="Email"
onblur="if (this.value == '') {this.value = 'email#abc.com';}"
onfocus="if (this.value == 'email#abc.com') {this.value = '';}" />
The initial value is set to "email#abc.com" but i want to change the text color to a grey only if they have not typed in the text field.
I also have the problem of different browsers having dropdown menues of words the user has typed in other input fields on other websites. how can i clear the list the browser generates?
Regarding auto-population, have a look at How do you disable browser Autocomplete on web form field / input tag?
With regards to a "watermark", I would suggest (if you're not opposed to jQuery) placeholder plugin (However I'm sure there are a lot of options if you google "placeholder", "watermark" and "html" (or any combination thereof))
As an aside, I would keep the formatting in a set of <script> tags and leave the markup on its own. Markup should be markup; javascript should supplement that separately and not in-line with the tags)
The color can be changed in the event handlers you already have and calling this.style.color = "grey"; if you want a cross-browser solution, but HTML5 includes the placeholder attribute, but is not well supported at this time.
To stop the code from getting hard to read in the event handlers, I suggest putting event handlers in <script>.
<script>
document.getElementById('Email').onblur = function() {
if (this.value == '') {
this.value = 'email#abc.com';
this.style.color = "grey";
}
else {
this.style.color = "black";
}
};
// etc.
</script>
To stop autofill, use <input autocomplete="off" /> (StackOverflow Answer)
<input type="text" onblur="if(this.value==''){this.value='Enter your email address'};" onfocus="if(this.value=='Enter your email address'){this.value=''};" value="Enter your email address" size="10" alt="username" class="bt login_input" id="mod_login_username" name="username">
refer this website .
http://www.mrmachinery.com/
use firebug