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 6 years ago.
Improve this question
Okay my question is, how can I request from user when clicks on button to enter his email and receive message with link of my web page?
You cannot do this with just HTML or even with just HTML and javascript.
To send an email, you need to use a back-end script, which is usually PHP (on most shared hosting servers) or asp/.Net (on Microsoft web servers)
Javascript has been made much easier with the jQuery add-in. Here is a link to some free videos about how to use jQuery. Basically, jQuery cuts typing dramatically and makes javascript much easier. All you need to use jQuery is to include the jQuery library between script tags -- place that code just above the closing </body> tag.
Here is some example code using jQuery, just to show what it would look like. This example:
* asks user for email address (but does not validate what they enter)
* creates a form with an element named eml that contains what the user typed
* submits the form to a backend PHP file called sendcontact.php. It is up to you to also write sendcontact.php
$(document).ready(function(){
$('#mybutt').click(function(){
var em = prompt('Enter your email');
$('body').append('<form id="yrForm" action="sendcontact.php" method="post"><input name="eml" value="' +em+ '" ></form>');
$('#yrForm').submit();
});
}); //END document.ready
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button id="mybutt">Click Me</button>
Now, you need to have another back-end file, sendcontact.php that will receive the data sent via the form, and send an email. Here is an overview of how to do that:
http://tangledindesign.com/how-to-create-a-contact-form-using-html5-css3-and-php/
(You can ignore the entire first part of the above tutorial that deals with creating the contact form. You only need to read about how to receive the information in PHP and send the email.)
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I have this project in Laravel and I have this list of emails in a html table ,each row has a checkbox, if I check X checkboxes I want to send a email to all of them.
Not worried about the email procedure but it will be in a php file, what I dont know is how to do the logic, should I encapsulate all of the table in a form with the action going to the php file or should I control this with a jquery ajax call.
Encapsulate the checkbox with a form :
<form action="script.php" method="post">
<input type="checkbox" name="mailadre#gmail.com">
<input type="checkbox" name="otheradre#yahoo.fr">
....
<input type="submit" value="Send Request">
</from>
Only the checked checkboxes will be send by the browser and receive by php. In fact on the php side, on script.php $_POST will be an array containing the checked mail adresses :)
EDIT :
If you don't want to reload the page and get acualized data you will have to use javascript with ajax calls.
You have to include a js script in your html that fetch a php page every x seconds to get the actual amount of orders and replace the value in the browser. This php page job will be only to display this number.
Ajax calls are executed after the browser get the page from the server, they are executed by the browser. As soon as PHP server send the page, it care no more, the only way to interact with it is by the client browser, in this exemple with an Ajax call to an url on the server that will repond only with the total amount of order. So in background of the browser it will require actualized datas to the PHP server.
To be honest JSON is probably the way you should go to be able to send total amount of order + all kind of other actualized infos to include in your page.
It would give you for exemple something like that {totalOrder = 142, lastConnection = "Jean-Philippe", LastOrderDate= "2020-11-18"} if you encode this array on the PHP server side:
$result = [ "totalOrder " => 142,
"lastConnection " => "Jean-Philippe",
"LastOrderDate"=> "2020-11-18"];
header('Content-Type: application/json');
echo json_encode($result);
Then you can easily replace content in your HTML page in javascript with this JSON response from your PHP server.
See detailed exemple here :https://makitweb.com/return-json-response-ajax-using-jquery-php/
Have a nice day.
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
Is there any way to generate webpages dynamically.for example I have a website called abc.com in which I have included a form with many fields.
When a user submit this form,I want a new webpage abc.com/xyz to be created.Wondering if this is possible.
Of course it's possible. Anything is possible in programming/development.
See the following PHP manual for a good tutorial: http://www.php.net/manual/en/domdocument.savehtmlfile.php
This is possible in variety of ways.
You can pass GET variables in URL (example.com/page?var1=1&var2=2) and use this variables to generate unique page by predefined template.
If you don't want to use variables in URL, you can POST them to page via form request or ajax call.
Alternatively you can use .htaccess configuration files to rewrite your URL and use url segments as variables (example.com/var1/var2), this is common approach in MVC systems, where first/second variables are class/method names.
So here's an example:
You have a page.php where form resides.
User fills a form and submits it.
Form goes trough AJAX call, submitting it to request.php page
request.php parses it and stores it in DB, generating unique id
AJAX event recieves from request.php a unique id and redirects user to review.php
with url (example.com/review/uniqueID) or (example.com/review.php?uniqueID)
review.php recieves uniqueId, get's info from DB by it and displays requested info
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 9 years ago.
Improve this question
I have a simple page that shows 4 different divs, all with a <h1> title (or other tag that shows text) and a form (with 1 input text) and a submit button... so far so good.
My answer is simple: I am looking for a way that:
when the user inserts a text and submit the form, the <h1> title shows the text that the user wrote
the form disappear (or takes style display:none)
this will take effect even if I refresh the page or view page in a different computer (probably need to save the data in a DB)
restart this process from the beginning (even if I need to code again).
This is for a mini game to provide to users 4 different choices and, if the user A select option 1, the <h1> will show text something like "User A was the first to choose this option. Please select a blank option" and, after the 1st raw over (point 4 described above), restart all forms.
NOTE: I am not asking in the way to "please do the code for me". I also searching for a way to store data in <php ?> - finding redbeanphp project.
I am also a newbie in SQL (just started to study SQLi last month to android development). My question is ONLY to looking for the best way to do this and what I need.
This would be the workflow:
When you click a button to submit the form JavaScript will send the form data to the server as an AJAX request and wait for a response from the server.
The PHP code on the server will read the data from the AJAX request and save it in a database and echo a success response along with the text to display.
Your JavaScript will receive this success message and hide form from the DOM and display the text in the header.
If you want the data to persist on the page on reload then you can save a flag in PHP session. Sessions persist in until you close browser window.
4.1 Use another AJAX call remove the flag from the session and reload the content.
So, if you are good with HTML and CSS you need:
JavaScript, AJAX, a JavaScript library to make things easier such as JQuery.
A server side language such as PHP.
A database to persist data. There are many choices. I am going to recommend MySQL just because there so many tutorials for it out there.
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
Suppose i have an array which contains 500 names and there mobile number...
Eg -
$ar=array("98738383839"=>"name1","4343243332233"=>"name2")
Now what i want to do is give a list of 4-5 people with radio button for the user to select 1... It can me starting 4-5 peoples from the array..
Now i want to give the a search box where they can start writing name and the list of 4-5 friends with radio button changes according to that only...
For example
I would recommend you look at angular as it is much easier than jQuery. I am currently doing a project in angular, and here is how I would approach it.
Go to: http://angularjs.org, then scroll down and look at example 3. The search is very powerful and easy to implement. Implement a simple type ahead in angular, which searches the array as user type.
For the boxes with radio button, it can be easily done in angular since it allows bidirectional data binding, which means if u change a value in JavaScript variable it would also change in HTML.
Basic introduction
For your text box include something like this in HTML. This will look for an array called itemLists (you will need to define as $scope.itemLists in your controller).
<input type="text" ng-model="searchRecord" placeholder="Enter to search..." typeahead="itemList.item_id as itemList.name for itemList in itemLists | filter:$viewValue">
Then you need a http request that looks something like the following. The PHP file will query mysql and return a set a results.
$http.get("someFile.php").success(function(response) {
if(response){# store results into itemLists array}
});
Then for the boxes, you create soemthing using CSS + or bootstrap either way, get it to look how you want it to look. Then for images, Email and radio button. Use ng-model just HTML input textbox in the html example code above.
<input type="radio" ng-model="radioButton1">
<input type="radio" ng-model="radioButton2">
...
ng-model is a bidirectional binding variable, you can access it both from HTML and JS. The value is instantly updated no matter where you change it.
Hope it helps, if you need more information the angular site is always a good place to start.
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
This isn't really a problem so much as a general question. I don't have much experience with javascript, and I wrote this a few months ago and now I can't remember why it works. I have the following code in a php file:
echo'<SCRIPT type="text/javascript" src="button_js.js"></SCRIPT>
<input type="text" placeholder="Enter Nickname" name="nickname" id="nickname" />
<br />
Submit Request |
Continue Searching';
Inside button_js.js, there is a submit_request function and a continue_searching function. When the user clicks the corresponding link, the appropriate function executes just like I want it to; everything works perfectly.
The problem is that I can't remember for the life of me why this works. How does it know to execute the correct function based on the user clicking on the link? I don't have an onClick in there anywhere. Is it just because the names of the functions match the id's of the links?
Thanks for your help!
Without seeing the code in your script, I can only guess... But it's very likely you are adding an event listener (sometimes incorrectly called an "event handler", which is different but related to your question).
In short, JavaScript has the ability to "grab" elements in your page and "listen" for events that might happen to them (such as click). Once that event happens, you trigger a function (or "handle" that event with an... "event handler").
If you're using jQuery, the concept is the same, however you may find that you're using jQuery's own event handling functions.
Providing the relevent JavaScript code would help others help you.
With that said, I will give you a general answer.
There is an event listener that fires when the user clicks. When the event fires, it gets value of the id attribute. Then, if the id attribute has a function name that corresponds to its value, the event then calls that function.
E.g., in JQuery (completely untested):
$("a").click(function(ev) {
var f = this[ev.target.id];
if (typeof f === 'function')
f(); // calls the function whose name corresponds to the id attribute
});