1

I am trying to write a program that will prompt you to enter someone's name. Then it will take that name and send it to a different program where it will add that name to its database. Here is the code:

<!DOCTYPE html>
<html>
<body>

<form name="customerForm" action="" method="get">
First Name: <input type="text" name="firstname" /><br />
Last Name: <input type="text" name="lastname" /><br />
<input type="button" name="button" value="Add Customer" onClick="addCustomer(this.form)">
</form>

<script type="text/javascript">
function addCustomer(form)
{
    var x = form.firstname.value;
    var y = form.lastname.value;
    var name = x+" "+y;
    alert(name);
}
</script>
</body>
</html>

Currently I have the javascript function to put the name into an alert box to see if it worked.

5
  • 3
    What's the question? How to send the data to the server? Commented Jun 18, 2012 at 15:32
  • 1
    Be clear which program,language etc. Commented Jun 18, 2012 at 15:36
  • I am using javascript and html to find a solution and pass the data (aka the name) into a SQL server database. Commented Jun 18, 2012 at 15:40
  • 3
    How can this question have 3 votes up? Commented Jun 18, 2012 at 15:40
  • How can this question have 2 downvotes? Commented Jun 18, 2012 at 15:44

2 Answers 2

0

Specify the URI to the program in the action attribute and change type="button" to type="submit".

The specifics of reading the data will depend on the language you write the program in and how it interacts with the webserver.

Sign up to request clarification or add additional context in comments.

Comments

0

Save to database via Ajax using jQuery, php, mysql

So you can use Ajax on jQuery to send a form result to a PHP page, then you have to write the PHP to handle converting that data and sending it to your database.

Exmample of sending with jQuery Ajax, from similar question

//ajax server call
$.ajax({
  url: '/useradminpage?main_id=%s&display=false',
  success: function(data) {
  //do some stuff.
  alert('returned');
 }
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.