Use text of text form for value of another? - html

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

Related

How to have 2 textboxes as mutually exclusive in an html form?

I would like to have 2 mutually exclusive fields.
One will be a FileField and other TextBoxField.
Is there a ready html form I can get my hands on to.
I have searched the web and couldnt find any.
Oh I am a little sorry..
I meant that I wanted to do this via Django Templates
You can make an onInput event listener and handle it using javascript, so that if the user types in one field it empties the other.
For example:
<form>
<label for="first">Fill This:</label>
<input type="text" name="first" id="first" oninput="run('first')"><br><br>
<label for="second">Or This:</label>
<input type="text" name="second" id="second" oninput="run('second')"><br><br>
<input type="submit" value="Submit">
</form>
<script>
function run(activeField) {
if (activeField == 'first') {
const second = document.querySelector('#second')
second.value = ''
} else {
const first = document.querySelector('#first')
first.value = ''
}
}
</script>
For Your textbox, you can use this:
<input type="text" name="name" placeholder="Please enter your name">
And for your files:
<input type="file" name="fileName">
But for file name it needs to be encrypted. HTML won't let you submit a form with a file. But you can override this in the form attr, like this:
<form action="dirToForm.py" method="POST" enctype="multipart/form-data"></form>

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>

HTML submission form without the use of back-end scripts

I'm making a HTML submission form and I want to have the form emailed to my email address without using a PHP script since Github Pages doesn't support it.
<form action="MAILTO:shirui.wang#hotmail.com" method = "post" enctype = "text/plain">
<p>Email Address:<input type = "text" placeholder = "Email Address:" size = "40" id="Email"></p>
<textarea rows="4" cols="50" id = "Textbox" placeholder="Enter your feeback here:"></textarea>
<p><input type="submit" value="Submit" id = "Submission"></p>
</form>
Right now, when I press submit, it will open my email client but the message I typed into the textbox does not copy over into the email message.
How do I get the content of the textarea to be copied into message part of the email?
You have to do this with javascript:
you need an a like this:
<form id="themagicform" >
<textarea id="yourtextarea"></textarea>
<a id="ThemagicA" href='mailto:me#me.com?subject=Me&body=textofemail'>Mail me</a>
</form>
and then use jquery or javascript to change textofemail when they press submit:
$("themagicform").on('submit', function(){
var hrefStr = $('themagicA').attr('href');
var text = $('yourtextarea').text();
hrefStr.replace('textofemail', text);
$('themagicA').attr('href', hrefStr);
});
Done :), hope it's works.
In HTML you can specify a mailto: address in the <form> element's [action] attribute, The [Action] is what opens the email client the method="GET" populates the form.
<form action="mailto:youraddr#domain.tld" method="GET">
<input name="subject" type="text" />
<textarea name="body"></textarea>
<input type="submit" value="Send" />
</form>
What this will do is allow the user's email client to create an email and the GET will pre-populated with the fields in the <form>.

Sending an email from HTML [duplicate]

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)

HTML field formatting

I have a standard HTML form.
<form method="post" name="myemailform" action="form-to-email.php">
Enter Name: <input type="text" name="name">
Enter Email Address: <input type="text" name="email">
Enter Message: <textarea name="message"></textarea>
<input type="submit" value="Send Form">
</form>
The problem is that when a value is input that is larger than the field size, upon clicking away, the field skips back to the beginning of the field so the end is cut off.
Is there a way to get it so that the view of the field stays where the carat was?
This is a javascript problem (client side), not a PHP one (server side).
You need to do this:
<input type="text" name="name" size="10" onblur="if (this.length > 10) {this.dir = 'rtl';} else {this.dir = 'ltr';}">
just check what is the proper length to use in order to change the input direction
You can use the HTML attribute size.