473,408 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Form Mail Variable Concatenation

I have a form page that accepts a text field variable. The problem is, I
need to concatenate this text field variable with some other string. How
can I get this done?

So, suppose a user enters "hello" in the text box. When he submits the form
I need the form variable DOMAINURL to be "hello.whatever.com" in the GET
url. Will this require javascript or no? If so, what do I need? Thanks.
Sep 16 '05 #1
3 2124
Shabam wrote:
I have a form page that accepts a text field variable. The problem is, I
need to concatenate this text field variable with some other string. How
can I get this done?
String concatenation is done through the overloaded + operator.
So, suppose a user enters "hello" in the text box. When he submits the form
I need the form variable DOMAINURL to be "hello.whatever.com" in the GET
url. Will this require javascript or no? If so, what do I need? Thanks.


Suppose you have a form like so:

<form action = "url" method = "get" onsubmit = "return
myFormHandler(this)">
....
<input type = "text" name = "myTextBox"/>
<input type = "hidden" name = "DOMAINURL"/>
....
</form>

Then in the javascript you can do something like the following:

function myFormHandler(myForm)
{
if(myForm.elements["myTextBox"].value != "")
{
myForm.elements["DOMAINURL"].value =
myForm.elements["myTextBox"].value + ".url.com";

return true;
}

return false;
}

Hope this helps :)

Sep 16 '05 #2
ASM
Shabam wrote:
I have a form page that accepts a text field variable. The problem is, I
need to concatenate this text field variable with some other string. How
can I get this done?

So, suppose a user enters "hello" in the text box. When he submits the form
I need the form variable DOMAINURL to be "hello.whatever.com" in the GET
url. Will this require javascript or no? If so, what do I need? Thanks.


on ne comprend rien à ce charabia

What do you say ?

show an example of your code
and ask what, where, and when, you want something
--
Stephane Moriaux et son [moins] vieux Mac
Sep 16 '05 #3
["Followup-To:" header set to alt.comp.lang.javascript.]
On 2005-09-16, Shabam <ch*****@yomama-nospam.com> wrote:
I have a form page that accepts a text field variable. The problem is, I
need to concatenate this text field variable with some other string. How
can I get this done?
In javascript + is used to concatenate strings
So, suppose a user enters "hello" in the text box. When he submits the form
I need the form variable DOMAINURL to be "hello.whatever.com" in the GET
url. Will this require javascript or no? If so, what do I need? Thanks.


try this.

<form method="get" action="whatever" >
<input type="hidden" name="DOMAINURL" id="magic" />
<input onchange="document.getElementById('magic').value=t his.value+
'.whatever.com'"/>
<input type="submit"/>
</form>

--

Bye.
Jasen
Oct 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: lawrence | last post by:
If I'm pretty sure there is just one form on the page, can i do this? var myForm = document.forms; If I'm not sure about the form, is it safer to do this? if (document.forms) { var myForm =...
1
by: cartoonsmart | last post by:
Hi I got the following script going; <?php $sendTo = "myemail@myemail.com"; $subject = "My web site reply"; $headers = "From: " . $_POST; $headers .= "<" . $_POST . ">\r\n"; $headers .=...
6
by: Leszek | last post by:
Hi. I wrote a script: function zmiana(ile){ while(document.getElementById('accomp').childNodes.length>1){ ostatni=document.getElementById('document.dane.accomp').lastChild;...
5
by: Openside | last post by:
Hi, I am fairly green when it comes to JavaScript. I have the Form Validation below for 3 textarea fields. It works fine, but if none of the fields are filled out then 3 consequtive alert...
27
by: Scott | last post by:
I've been trying to come up with a way to ensure user input is coming from the form on my site, and not auto-submitted from elsewhere, and I don't want to use the "enter the code shown in the...
7
by: h7qvnk7q001 | last post by:
I'm trying to implement a simple server-side form validation (No Javascript). If the user submits a form with errors, I want to redisplay the same form with the errors highlighted. Once the form...
3
uranuskid
by: uranuskid | last post by:
Hey folks, I was going to include a contact form on my website. Well, in the first place that seemed an easy thing to do with a form that prompts a PHP file validating the input vaiables and using...
4
theaybaras
by: theaybaras | last post by:
Hi everyone, You've all been such a huge help to me since joining, and I'd just like to take a second to let you know how much I appreciate it! That said, I have another supplication! ;) I have...
3
by: RLN | last post by:
I have an app that will send out an email periodically. My table has one row and three columns: a primary key, an "EmailFrom" Address and an Email template. The template is the text of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.