Click to See Complete Forum and Search --> : Javascript Button Forms
paddywhistler
01-13-2004, 01:35 PM
Hi Everyone,
Wondering about help please - I have a webpage inputPage.html with a form frmInputForm and input fields for name, age & email. I have validation checks set up for these fields which work and are activated by a button using onclick and calling on multiple functions.
What I need to do is when the Submit button is clicked, the validation functions are run and if all entries are ok, automatically links to another webpage gamePage.html. Additionally I need to use the name field from the inputPage to say either in a message box or just written to the gamePage for customisation saying something like Welcome "name".
I think it has something to do with document.write, but not sure if it is possible to run the functions then link or to use form fields from one page to another.
Can anyone HELP...........PLEASE!!!!!!!!!!!!!
Thanks,
Emma
Khalid Ali
01-13-2004, 01:42 PM
if you want to submit a form and then redirect to another page( different one),then you will need to use server side languages such as
php,jsp asp etc
JeanNick
01-13-2004, 01:43 PM
To send infos from your form to the gamePage.html, in your form you set method=post action=gamePage.html
It will bring you to gamePage.html with all the infos within your form.
Now.. for your validation functions and redirection if inputs are wrong, I would use php or asp for your gamePage.html and let it handle both possibilities.. success login or not.
paddywhistler
01-13-2004, 03:15 PM
Thanks for the rapid responses, will be back again!!!
JeanNick - I've integrated your suggested code but no difference.
Bit more of explanation of what I have and what I need:
InputPage.html
Form is completed - name, age, email
Submit button is clicked - onclick calls validation functions which alert, reenter, (sort of try again, rather than redirect no access, no username login etc required)
When all entries reentered to become valid (or if valid from first entry), submit button links to my next page
GamePage.html
Opens simple game with a bit of customisation using name value from previous page form.
Any further suggestions would be gratefully tried and tested.
Thanks again,
Emma
codemullet
01-13-2004, 03:25 PM
if you're using asp:
give each input field a name
ex: <input type="text" name="Age">
when you submit to the next page, use the Request function
ex: Request("Age") to grab the value from the previous page
paddywhistler
01-13-2004, 03:29 PM
Hi Khalid Ali & JeanNick,
Just linked to the tips on postings provided and realised you might not pick up my previous reply due to subject given.
Hopefully this will be flagged so you see it - not sure if you look at the whole forum or just relevant subject matter!
Thanks,
Emma
paddywhistler
01-13-2004, 03:37 PM
Hi Codemullet,
Not using ASP at all only Javascript & HTML - only 3 page simple game site, welcome page, input page, game page.
Anyway all fields in the form are named for that same reason (in theory anyway!) as below:
<input type="text" value="" maxlength="24" name="name">
The validation checks call on the field name in the functions, so they're definitely named correctly.
Just don't know the code for reuse of a form field on another page. I've tried:
function write_this()
{
document.frmInputForm.name.value =
document.gamePage.frmWelcomeForm.name.value;
}
and added a form with a name field to the gamepage, but this doesn't work, not sure if I'm going on the right track?!
Always ready for new ideas/suggestions....
Cheers,
Emma