I am new in Javascript and I would like to make a small offline tool that opens up Outlook, and presets the email in the "To" section, presets the default Subject, and presets the body of the email with text from a textarea.
I would need the text area so that I can modify the email content whenever I want.
For now, I have the following code:
<form method="post" action="mailto:yourname#yoursite.com" enctype="text/plain">
<input type=text name=your_content>
<input type=submit value="Submit Your Content">
</form>
However, when I submit, Outlook opens, and the name attributes' values appear before my text.
Is there a way to avoid adding the name's value in my email, replace input with textarea and add the above mentioned things?
Thanks!
Try switching the method to GET so it behaves more like an anchor tag and puts your values into url parameters instead of a post body. You will have to set the input names to valid mailto: values like body & subject
<form method="GET" action="mailto:yourname#yoursite.com" enctype="text/plain">
<input type=text name="body">
<input type=submit value="Submit Your Comments">
</form>
note that there is a max url size of ~2k characters
Related
As you know, the <input type="text" name = "input_field"> element creates a space for the user to type in an HTML form. But in this case, I know what the user is going to enter.
For instance, the user wants to send 'hello' to the action page. It isn't a particular piece of information like his/her name, email id, etc. It will be the same for everyone. Then why not just create a button like this:
<input type="submit" value="click to send 'hello'">
When the user will click on the button, 'hello' will be sent to the action page specified in the action attribute of the <form> element.
How do I do it? Also, I need to mention that I am not much experienced in HTML or JS, so I would appreciate a beginner-like solution.
I apologize if this question already exists somewhere.
Thanks in advance!
You can include predefined information when submitting a form by using a type="hidden" field:
<input type="hidden" name="input_field" value="hello">
That doesn't appear visibly on the page, but is submitted just like any other field when you submit the form.
As far as I understand your problem, you want to create a form where few fields will have predefined information
I would suggest not to hide the input according to the UI/UX perspective but instead, you can show those fields as read-only.
In this way, the user will have an idea of predefined values
<form action="/action_page.php">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<input type="number" disabled readonly id="custId" name="custId" value="3487">
<input type="submit" value="Submit">
</form>
I have to send text field value using href to php is something like below. But it is not correct way. Can anyone please give me any solution?
<input type="text" id="myText" value="Mickey">
<a href="test.php?id=javascript:document.getElementById('myText').value;">
<input type="button" value="Click"></a>
Put content inside a form. You can also change the button type input to a submit type, this way the form is sent automatically on click.
<form method="POST" action="yourURL.php">
<input type="text" id="myText" name="myElement" value="Mickey">
<a href="test.php?id=javascript:document.getElementById('myText').value;">
<input type="submit" value="Click"></a>
</form>
More information on forms: MDN
Whether you use GET or POST as a method, you'll be able to access the content of the form through PHP variables: $_GET, $_POST or the generic $_REQUEST.
More information in the PHP documentation
Note: PHP uses the name attribute of your HTML elements for those variables. Make sure to add this attribute to your HTML elements otherwise you'll have a hard time getting a value from $_REQUEST['myText']. I added the attribute holding the value "myElement" in the above code. It is accessible through PHP by typing $_REQUEST['myElement'].
Content sent through GET method is visible in the URL,
like this: www.example.com/test.php?var1=test&var2=test
<input type="text" id="myText" value="Mickey">
test
I wanted to know if it possible to make a form where one could change the email to which the mailto action is set, to what is entered in the text field.
for example:
<form enctype="text/plain" method="get" action="mailto:getElementByName='friend1'" action="cc:manager#crill.com">
Friend 1 <input type="text" name="friend1"><br>
Friend 2 <input type="text" name="friend2"><br>
Friend 3 <input type="text" name="friend3"><br>
<input type="submit" value="Send">
</form>
So if in the first field named "Friend 1" I would enter: "example1#mail.com", then when I press submit I wanted it to take the info that was placed into the first field and make it the mailto.
I apologise for my english, hope whom ever reads this understands it.
Thank you in advance.
You could do it by using:
<form method="post" action="javascript:;" onSubmit="this.action='mailto:'+document.getElementById('friend1').value;" enctype...>
Check here too: Is it possible to dynamically set the recipient of MAILTO: with only HTML and JavaScript?
I am having a simple form following is the code
<form action="search.html" method="get" accept-charset="utf-8" id="search-within-form"">
<input type="hidden" name="within" id="within" value="">
<input type="text" name="q" value="" id="search-within" autocomplete="off" class="search-within-results inactive" title="">
<input type="submit"/>
</form>
I am entering test data for search in the field and click submit, in the URL I see is
/search.html?within=&q=test+data+for+search
But I need the url to be like tis
/search.html?within=&q=test data for search
I know this can be done by using java script form submit etc.. I like to know is there some way I can achieve this using html?
Thanks in advance.
Your URL will never display that way in a browser. Either the text will be seperated by those '+' characters or it will be seperated by '%20's. Is there a reason you need the URL to display in that fashion? Ultimately it comes down to how the browser displays the URL in the address bar. '%20' is code for a space. You might be able to develop a browser extension that would make them display with the spaces, but that sounds pretty terrible to me.
Why don't you clean the text at the place you retrieve the value from the form ? Is there any reason why you can't do that ?
I want to create a browse button so i found this code : and it works fine
<form action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi"
enctype="multipart/form-data" method="post">
<p>
Type some text (if you like):<br>
<input type="text" name="textline" size="30">
</p>
<p>
Please specify a Test , or a set of tests:<br>
<input type="file" name="datafile" size="40" >
</p>
<div>
<input type="submit" value="Execute Test">
</div>
</form>
But in my case the browse functionality should begin from a specific URI (C:\software\apache-tomcat-7\apache-tomcat-7.0.28\wtpwebapps\WebTestAutomatisation\WEB-INF\classes\functional)
So i want to fix the initial uri
I make a search in the input tag attributes but i didn't find anything useful
You want to change the default path when the user click on "browse" ?
I think it is not possible to change the default path of an input type files because it can be a big security hole...
I don't think what you are trying to do is possible. Like #ClementAndraud pointed out, this can be a big security hole if it is allowed. meanwhile you can check this post for further clarification.