katia Posted May 29, 2006 Share Posted May 29, 2006 When I submit a form I need to load different web pages, acording to some text values the users writes in 2 text boxes : form.textbox1.value and form.textbox2.value . Is there any way I can do that?//this is the piece of my code where i have to do that<form name="formlog" onsubmit="return test(formlog)" action="THECONCATENATEDSTRING "> Link to comment Share on other sites More sharing options...
scott100 Posted May 29, 2006 Share Posted May 29, 2006 Try something like this: <head><script>function go(){var page="";page+=document.form.textbox1.value;page+=document.form.textbox2.value;document.form.action=page;document.form.method="post";document.form.submit();}</script></head><body><form name="form">Address 1: <input name="textbox1" type="text" />Address 2: <input name="textbox2" type="text" /><input type="button" value="submit" onclick="go()" /></form></body> Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 31, 2006 Share Posted May 31, 2006 This might (and I say might) not work in every browsers, as I got troubled with them: document.formThis way you call to the form by the name as an object.If you do it this way, it should work anyhow:document.forms['form'](where the green is the form's name )Or this way, if you are aware of what number the form is indexed:document.forms[0] Link to comment Share on other sites More sharing options...
scott100 Posted May 31, 2006 Share Posted May 31, 2006 I would have thought this would work in most browsers but i can't be sure To be honest this is not the method i use when accessing form information, i use document.getElementById('id').value.I was just continuing along the lines of the topic starter: form.textbox1.value Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 31, 2006 Share Posted May 31, 2006 I know, but this is what I've learned from the javascript tutorial And any other way would cause in FF some errors so I have heard Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now