Send an email from HTML / Java script [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a simple html page which should take the input from text box and send that as an email.
function getData()
{ var txt=document.getElementById("result").value; }
<body>
<form>
<input type="text" id="result" size="20">
<input type="button" onclick="getData()">
</form>
</body>
Now i need to send the value of txt as email. Whats the easiest way to achieve that? I am familiar with Java/ Java script. I have no hands on PHP.

You cannot send an email using client-side JavaScript.
You will need to submit the form to a server side script which can send the mail for you.
This is not too difficult using PHP, so I urge you to read up on it. Here's a good link: http://code.tutsplus.com/tutorials/sanitize-and-validate-data-with-php-filters--net-2595
<form action="myscript.php">
<input type="text" name="message" size="20">
<input type="submit" value="Send mail"">
</form>
Then in myscript.php:
<?
$message = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
mail("someone#example.com","My subject",$message);
?>

Related

Trying to pass my search result from my search website to another search website [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am trying to pass my search term from my site into the string of another site's URL link. This will allow the search to find books on my site and if it can't be found there the user would click a button that would take the string from the search field and pass it to the URL of MnLink.org. I know my sites code is as follows.
Search For:
I can't figure out what I am missing because I am new to HTML and a novice in JavaScript. I thought I could put the value or id in as a var in a script but I could not get that to work. below is what I have started but got stuck on, any help would be great.
https://mnlink.on.worldcat.org/search?='"style="padding-left:10px;background:#ffffff; border: solid black;">Continue Search
You could simply use a form with method="get" and action="https://mnlink.on.worldcat.org/search".
EXAMPLE:
<form method="get" action="https://mnlink.on.worldcat.org/search">
<div>
<input type="text" name="queryString" value="" />
<button type="submit">
Submit
</button>
</div>
</form>
Working DEMO
EDIT
If you have to use an onClick event i suggest you to use Jquery: on click() you have to redirect your page with window.location.href = 'https://mnlink.on.worldcat.org/search?queryString=' but you must add the value at the end of that String with $("#INPUT_ID").val(). See the demo.
HTML:
<input title="Search For:" autofocus="false" accesskey="s" maxlength="256" tabindex="9" autocomplete="off" size="100" value="cats" id="q" name="q" type="text">
<button id="submit">
Search
</button>
JS:
$(document).ready(function(){
$("#submit").click(function() {
window.location.href = 'https://mnlink.on.worldcat.org/search?queryString=' + $("#q").val();
});
});
Working DEMO.

How to create 'add quantity' input box and embed it inside PHP scripts? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Thanks for those who helped! I have figured it out!
How can I create a input field like the one in the image? And I want to embed it inside $_POST. Thanks for your time :)
This is an HTML5 input of type number. You use it this way:
<form method="POST" action="yourPHPfile.php">
<input type="number" name="number_input">
<input type="submit">
</form>
When this form is submitted, it will send the selected number to yourPHPfile.php and you can retrieve the number from $_POST['number_input']
You can use input for the number selecotr and post using a form like so:
<form method="post">
<input type="number" name="intNumber"/>
<input type="submit" />
</form>
Then in PHP you can do this
<?PHP
if(isset($_POST['intNumber'])){
$myNumber = $_POST['intNumber']; // intNumber is the name of of your input
}
?>
When the submit button the PHP will be fired.
Hope this helps!

Php form submit alert if less than 1min passed [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need some help with my php code
<?php
date_default_timezone_set('America/Los_Angeles');
$now = date("H:i:s");
?>
<form method="post" name="update" action="update.php" />
<input type='text' name='fname' value=''>
<input type='text' name='lname' value=''>
<input type='text' name='email' value=''>
...
<button type="submit" value="Submit"/> Submit </button>
</form>
What i need:
If someone clicks on button submit but it passed less than 1 min since start($now)
then it must appear an Alert "Check Info"(not another page or popup),
an alert like "Do you really want to leave the page?"
I should not work for free... but I won't give you the full answer!!! Make an effort and fill in the right code <<< FILL >>> to get it to work!!!
<script src="<<<FILL>>>"></script>
<script>
submitAllowed = false
$("form").submit(function(e){
e.preventDefault();
if (<<<FILL>>>||confirm("Do you really want to leave")) {
this.submit()
}
});
function submitAttempt(){
submitAllowed = true;
}
setTimeout(<<<FILL>>>, 60000);
</script>

Keeping entered value on html <textarea> with pages having multiple <form> [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My php page consist of a number of textfileds and textareas in which the user can input their details there. these textareas and textfileds are inside a <form></form>.so when clicking on submit button all those values are posted (form method=POST ).
there are 2 <textarea> named as Permanent Address and Communication address. and also a check box "Communi. address is same as permanent". the check box code is follows
<input type="checkbox" id="checkadd" onclick="if (this.checked) copyAddress (this.form)"/>
this function calls copyaddress function that copy the Permanent address to Communication address <textarea>. " copyAddress (this.form) " will copy the value of 1st <textarea>(permanent address). so i don't get the value of Permanent address in the page in which i have to POST this value too to the Next Page.
Can you try this..
<?php
if($_POST['permaddress'])
{
echo $_POST['permaddress'];
echo $_POST['commaddress'];
}
?>
<script>
function copyAddress()
{
if(document.getElementById('checkadd').checked == true)
{
document.getElementById('commaddress').value = document.getElementById('permaddress').value;
}
}
</script>
<form method="post" action="test.php" >
<textarea rows="30"cols="30" name="permaddress" id="permaddress"></textarea>
<textarea rows="30"cols="30" name="commaddress" id="commaddress"></textarea>
<input type="checkbox" id="checkadd" onclick="copyAddress()"/>
<input type="submit" value="submit">
</form>

Can someone explain to me this javascript based internal website search script? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Can someone explain to me line by line what is happening in this script ? :
<script type="text/javascript">
function Gsitesearch(curobj){
var domainroot=curobj.domainroot[curobj.domainroot.selectedIndex].value
curobj.q.value="site:"+domainroot+" "+curobj.sitesearch.value
}
</script>
Thanks !
It's from here:
http://www.javascriptkit.com/script/script2/google_site_search2.shtml
The snippet, along with a <form> that submits to http://www.google.com/search, allows you to submit a search to google that limits results to those coming from the domain domainroot.
Full example:
<script type="text/javascript">
// Google Internal Site Search script II- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use
function Gsitesearch(curobj){
var domainroot=curobj.domainroot[curobj.domainroot.selectedIndex].value
curobj.q.value="site:"+domainroot+" "+curobj.qfront.value
}
</script>
<form action="http://www.google.com/search" method="get" onSubmit="Gsitesearch(this)">
<p>
<input name="q" type="hidden" />
<input name="qfront" type="text" style="width: 180px" /> <input type="submit" value="Search" /><br />
Search:
<select name="domainroot">
<option value="www.javascriptkit.com" selected="1">JavaScript Kit</option>
<option value="www.dynamicdrive.com">Dynamic Drive</option>
<option value="www.freewarejava.com">FreewareJava.com</option>
</select>
</p>
</form>
<p style="font: normal 11px Arial">This free script provided by<br />
JavaScript Kit</p>

Categories