Jump to content

how can I concatenate 2 strings?


katia

Recommended Posts

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

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

This might (and I say might) not work in every browsers, as I got troubled with them:

document.form
This 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...