olo
olo

Reputation: 5271

jQuery simple Data Pass HTML

I'm working on a HTML form, I'd like to achieve once the submit button hit, then goes to a confirmation page. The confirmation page get the data from form page.

As my form validation is used by jQuery, for example I have a variable name is VISITORNAME How to make the conformation page shows "THANK YOU VISITORNAME"

I did research, could not find a simple easy way to do it.

Upvotes: 1

Views: 177

Answers (4)

Soojoo
Soojoo

Reputation: 2156

Example:

**html**
 <form name='ff' id='test' action="javascript:void(0);">
 <span id='msg'></span>
 <input type='text' id='name'>
 <input type="submit" value='submit'>
 </form>

  **jquery**
$(document).ready(function (){
$('#test').submit(function(){
  if($('#name').val()!=''){
   $('#msg').html('Your custom message');
 }

});
});

Upvotes: 0

user1711180
user1711180

Reputation:

you have many ways to do that, one is to add something to the url when the form is submitted and read with js in the other page (this does not involve server side coding)

$(form).submit(function() {
  $(this).action += '#visitorname=whatever'
});

Then in the form you can get the visitorname from the url

var name = window.location.href.replace(/^.*#visitorname=/, "")

Upvotes: 3

Hidde
Hidde

Reputation: 11921

Make the comfirmation page a PHP page, and send some GET or POST values from the form with it.

Then echo your message:

echo 'Thank you, '.$_POST['visitorname'].', your form has been submitted';

Upvotes: 0

Adam Hopkinson
Adam Hopkinson

Reputation: 28795

Most forms use a server-side language, such as PHP or ASP.net. I suggest you read PHP's 'Dealing with forms' tutorial:

http://php.net/manual/en/tutorial.forms.php

Upvotes: 0

Related Questions