homepage Welcome to WebmasterWorld Guest from 54.221.175.46
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
I need a script
Need javascript to transport data
BrooklynB




msg:4048274
 1:18 pm on Dec 23, 2009 (gmt 0)

Anybody know of a Javascript (or any other kind) that can transport text from a form on one page into a form on another page? For example, on page1.html I want to have a box where somebody enters their email address. When they click "submit" they go to page2.html where their email address has been entered inot a form and they then must fill in more data before the registration is sent to the database.

 

chasehx




msg:4048457
 5:45 pm on Dec 23, 2009 (gmt 0)

That could be easily done with JavaScript or PHP.

In JavaScript or PHP, you could set a cookie to the user that is retrieved when the second form loads, and then is spit out into the fields that have already been filled out.

You could use AJAX programming to value check and insert the values into the database, or whatever other action, asynchronously, meaning no page reload. Hooray.

Perhaps the simplest way, and the way I would do it, is using a $_POST variable.

<input type="text" name="uniquename" />

on the next page, you would access the variable as such
$_POST['uniquename'];

Alternatively you could use $_GET and place the user value in to the browser request URI, but $_POST is more secure and when possible should be first choice.

BrooklynB




msg:4048565
 8:14 pm on Dec 23, 2009 (gmt 0)

Thanks. Since I am not an expert programmers, can you suggest where I can find a script that would do this?

chasehx




msg:4048597
 9:04 pm on Dec 23, 2009 (gmt 0)

Around the site the are excellent examples and tutorials. For a primer on PHP programming, start here:

[w3schools.com...]

Assuming you made the form on the previous page and have some understanding of PHP, on the page2.html or what have you, the variables from the form can be accessed as such:

$_POST['input_tag_name'];

Input tag name being of course, the value of the name attribute in the input tag. Once you have the variable, you could print it to an input field, which would allow further editing if desired, like so:

<input type="text" name="unique_name" value="<? echo $_POST['unique_name']; ?>" />

Does that help any?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved