conacatenation of variables

  • Thread starter Thread starter Russell
  • Start date Start date
R

Russell

Hello,

I would like to concatenate user input (variable1) with a constant or
variable2. Any help would be appreciated.

Russell
 
What language??

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
ooops,

In HTML I have a form with user input (variable1) I would like to
concatenate this with either variable2 or a constant.

Thanks,

Russell
 
You would have to learn to write JavaScript to accomplish client-side in the browser or learn
server-side scripting (ASP, ASP.net, PHP, etc.) to accomplish server-side.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
Thanks, but luckily they're are some MVP's that are willing to show someone
like me how to do this.
I don't remember who helped but someone (maybe Steve Easton) showed me how
to add 2 numeric variables from an html form.

<input type="text" name="amt" size="5" onblur="this.form.Total.value =
parseInt(this.form.constant.value) + parseInt(this.form.amt.value)"
maxlength="5">
<input type="hidden" name="amt2" onblur="this.form.amt2.value =
this.form.Total.value" >

But now I'd like to concatenate two strings, one, user input, the other a
constant.

Any help is greatly appreciated.

Thanks

Russell
 
What you have indicated below is JavaScript.

Well you didn't answer Steve's question regard the Language. HTML is not a language. It has to be
accomplished with either JavaScript or server-side scripting (ASP, ASP.net, PHP).

I rarely use JavaScript, outside of what is generated by FP for Form Field Validation, instead I
have learn to write ASP/VBScript to handle functions such as your request.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
Assuming javascript:
Make sure the variables are global, which means they are declared after the opening script
tag but before any functions.

<script type= "text/javascript">
var value1
var value2
var value3
function myfunction(){
value3 = 'value1'+'value2';
}
</script>

another way to concatenate strings inside the function is:

value3 = 'value1'\n;
value3+='value2';

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
Thanks Thomas,

I wasn't indicating that HTML was a language, rather I was working on a web
page in HTML and have an HTML form with elements I would like to
concatenate; and that someone was kind enough to help me before, with java
script, as you indicated. I am still hoping someone will guide me on this.
Thanks for YOUR help Thomas.

Russell
 
Well Steve, Thanks, I've been trying to no avail. Perhaps I should be more
specific.

I am sending data to a shopping cart. I need to have a user input fabric
colors and other variables. The shopping cart will display ONLY a list of
the user inputs,ie blue, green, etc. It will NOT display what the variable
refers to (fabric color, border color). So I would like to concatenate a
constant (Fabric color) with the users input called custom2.


I have the following:
<INPUT TYPE="HIDDEN" NAME="variable1" VALUE="Fabric color">
<select size="1" name="custom2">
<option value="White">White</option>
<option value="Black">Black</option>
<option value="Beige">Beige</option>
</select>
<input TYPE="submit" NAME="add" VALUE="Add to Cart">
</form>


I would appreciate it if you could be more specific as to what I need to do
to accomplish my goals.

Thank You,

Russell
 
Hi Russel,
So if the guy chose say beige what would you like to end up with?
FabricColor-beige in the field variable1? If so you can do
<script type="text/javascript">
function doForm(f){
f.variable1.value='FabricColour-' +
f.custom2[f.custom2.options.selectedIndex].value;
}
</script>
<input TYPE="submit" NAME="add" VALUE="Add to Cart"
onclick="doForm(this.form);">
 
I didn't know / you didn't say you were using an drop down select.
Jon Spivey has given you the correct answer.

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
Thanks Jon, that worked!!

<INPUT TYPE=HIDDEN NAME=custom3 VALUE="tempvalue">
<script type="text/javascript">
function doForm(f){
f.custom3.value='Fabric Color- ' +
f.custom22[f.custom22.options.selectedIndex].value;
}
</script>
<input TYPE="submit" NAME="add" VALUE="Add to Cart"
onclick="doForm(this.form);">
</form>

In the above, it only works if I make "reference" to custom3 before using it
in the function.

I have tried setting a variable = to the constant and then concatenate them
but could not get that to work. How would I code that? For example

<INPUT TYPE=HIDDEN NAME=custom4 VALUE="Fabric Color">
then concatenate custom 4 with custom22 from the user input??

Again, Thank You very much for your help.

Russell

http://www.annagraberoriginals.com/gloves.htm

The page in question...





Jon Spivey said:
Hi Russel,
So if the guy chose say beige what would you like to end up with?
FabricColor-beige in the field variable1? If so you can do
<script type="text/javascript">
function doForm(f){
f.variable1.value='FabricColour-' +
f.custom2[f.custom2.options.selectedIndex].value;
}
</script>
<input TYPE="submit" NAME="add" VALUE="Add to Cart"
onclick="doForm(this.form);">

--
Cheers,
Jon
Microsoft MVP

Russell said:
Well Steve, Thanks, I've been trying to no avail. Perhaps I should be more
specific.

I am sending data to a shopping cart. I need to have a user input fabric
colors and other variables. The shopping cart will display ONLY a list of
the user inputs,ie blue, green, etc. It will NOT display what the variable
refers to (fabric color, border color). So I would like to concatenate a
constant (Fabric color) with the users input called custom2.


I have the following:
<INPUT TYPE="HIDDEN" NAME="variable1" VALUE="Fabric color">
<select size="1" name="custom2">
<option value="White">White</option>
<option value="Black">Black</option>
<option value="Beige">Beige</option>
</select>
<input TYPE="submit" NAME="add" VALUE="Add to Cart">
</form>


I would appreciate it if you could be more specific as to what I need to
do
to accomplish my goals.

Thank You,

Russell
 
Thanks Steve,

Was my error , I didn't include all the info on what I was doing.

I have another question though about the code Jon gave me. On another site,
you or another MVP helped with some Java Sc ript math. That code was :
<input type="hidden" name="Total" value="0">
<input type="hidden" name="constant" value="20">
<input type="text" name="amt" size="5" onblur="this.form.Total.value =
parseInt(this.form.constant.value) + parseInt(this.form.amt.value)"
maxlength="5">
<input type="hidden" name="amt2" onblur="this.form.amt2.value =
this.form.Total.value" >

This works fine for adding a user's numeric input value to a constant.
There is no java script tag. How come we need it in the example Jon gave me
today but not in this one? And sint it possible to concatenate the same
way?

Thanks again,

Russell
 
Hi Jon,

This worked well, and again I thank you.

How would I do this for 2 or more variables? I have some forms that take up
to 4 inputs to describe the product. Example :
Fabric color
Lace color
Ribbon color

How would I go about repeating the code below 3 times, once for each
constant above?

Thanks

Russell

Jon Spivey said:
Hi Russel,
So if the guy chose say beige what would you like to end up with?
FabricColor-beige in the field variable1? If so you can do
<script type="text/javascript">
function doForm(f){
f.variable1.value='FabricColour-' +
f.custom2[f.custom2.options.selectedIndex].value;
}
</script>
<input TYPE="submit" NAME="add" VALUE="Add to Cart"
onclick="doForm(this.form);">

--
Cheers,
Jon
Microsoft MVP

Russell said:
Well Steve, Thanks, I've been trying to no avail. Perhaps I should be more
specific.

I am sending data to a shopping cart. I need to have a user input fabric
colors and other variables. The shopping cart will display ONLY a list of
the user inputs,ie blue, green, etc. It will NOT display what the variable
refers to (fabric color, border color). So I would like to concatenate a
constant (Fabric color) with the users input called custom2.


I have the following:
<INPUT TYPE="HIDDEN" NAME="variable1" VALUE="Fabric color">
<select size="1" name="custom2">
<option value="White">White</option>
<option value="Black">Black</option>
<option value="Beige">Beige</option>
</select>
<input TYPE="submit" NAME="add" VALUE="Add to Cart">
</form>


I would appreciate it if you could be more specific as to what I need to
do
to accomplish my goals.

Thank You,

Russell
 
I would assume there is a script located elsewhere in the page.

onblur is a reserved word ( sometimes called a constant ) in javascript
and doesn't need to be enclosed in script tags to function.
It automatically fires when a page is minimized, maximized or closed


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
The onblur is a javascript event that can trigger an action when an object on the page loses focus
- means when the form field (in your example the form field name="amt") loses focus (use leave the field) do something, and the do
some thing is:
Add to the field named "Total" the value of field named "constant" and the value of the field named "amt"

Since it is doing math the values of "constant" and "amt" are being parsed to integer first
- that is the reason they are surrounded by parseInt()

In your new case you are trying to concatenate strings, not numbers so you would not use parseInt

You could also use an event at each unique dropdown
But you would use the onchange event (instead of the onblur event)
- since the user is not typing anything but selecting a dropdown option (changing a selection) from a form field named FabricColor
(the below <select> opening tag all on 1 line)

<select size="1" name="FabricColor" onchange="this.form.FabricColor.value = 'Fabric Colour - ' +
this.form.FabricColor.options.selectedIndex].value";>
<option value="White">White</option>
<option value="Black">Black</option>
<option value="Beige">Beige</option>
</select>


IMHO
Frankly a lot of unnecessary javascript when you could just edit the form field values to include the desired full values as say:

<select size="1" name="FabricColor">
<option value="Fabric Color - White">White</option>
<option value="Fabric Color - Black">Black</option>
<option value="Fabric Color - Beige">Beige</option>
</select>
<select size="1" name="LaceColor">
<option value="Lace Color - White">White</option>
<option value="Lace Color - Black">Black</option>
<option value="Lace Color - Beige">Beige</option>
</select>
etc.
--




| Thanks Steve,
|
| Was my error , I didn't include all the info on what I was doing.
|
| I have another question though about the code Jon gave me. On another site,
| you or another MVP helped with some Java Sc ript math. That code was :
| <input type="hidden" name="Total" value="0">
| <input type="hidden" name="constant" value="20">
| <input type="text" name="amt" size="5" onblur="this.form.Total.value =
| parseInt(this.form.constant.value) + parseInt(this.form.amt.value)"
| maxlength="5">
| <input type="hidden" name="amt2" onblur="this.form.amt2.value =
| this.form.Total.value" >
|
| This works fine for adding a user's numeric input value to a constant.
| There is no java script tag. How come we need it in the example Jon gave me
| today but not in this one? And sint it possible to concatenate the same
| way?
|
| Thanks again,
|
| Russell
|
|
|
|
|
| | > I didn't know / you didn't say you were using an drop down select.
| > Jon Spivey has given you the correct answer.
| >
| > --
| > Steve Easton
| > Microsoft MVP FrontPage
| > 95isalive
| > This site is best viewed............
| > .......................with a computer
| >
| > | > > Well Steve, Thanks, I've been trying to no avail. Perhaps I should be
| more
| > > specific.
| > >
| > > I am sending data to a shopping cart. I need to have a user input fabric
| > > colors and other variables. The shopping cart will display ONLY a list
| of
| > > the user inputs,ie blue, green, etc. It will NOT display what the
| variable
| > > refers to (fabric color, border color). So I would like to concatenate a
| > > constant (Fabric color) with the users input called custom2.
| > >
| > >
| > > I have the following:
| > > <INPUT TYPE="HIDDEN" NAME="variable1" VALUE="Fabric color">
| > > <select size="1" name="custom2">
| > > <option value="White">White</option>
| > > <option value="Black">Black</option>
| > > <option value="Beige">Beige</option>
| > > </select>
| > > <input TYPE="submit" NAME="add" VALUE="Add to Cart">
| > > </form>
| > >
| > >
| > > I would appreciate it if you could be more specific as to what I need to
| do
| > > to accomplish my goals.
| > >
| > > Thank You,
| > >
| > > Russell
| > >
| > >
| > >
| > >
| > > | > > > TY Steve, much appreciated. I will try this and report back.
| > > >
| > > > Russell
| > > >
| > > >
| > > > | > > > > Assuming javascript:
| > > > > Make sure the variables are global, which means they are declared
| after
| > > > the opening script
| > > > > tag but before any functions.
| > > > >
| > > > > <script type= "text/javascript">
| > > > > var value1
| > > > > var value2
| > > > > var value3
| > > > > function myfunction(){
| > > > > value3 = 'value1'+'value2';
| > > > > }
| > > > > </script>
| > > > >
| > > > > another way to concatenate strings inside the function is:
| > > > >
| > > > > value3 = 'value1'\n;
| > > > > value3+='value2';
| > > > >
| > > > > --
| > > > > Steve Easton
| > > > > Microsoft MVP FrontPage
| > > > > 95isalive
| > > > > This site is best viewed............
| > > > > .......................with a computer
| > > > >
| > > > > | > > > > > Thanks, but luckily they're are some MVP's that are willing to
| show
| > > > someone
| > > > > > like me how to do this.
| > > > > > I don't remember who helped but someone (maybe Steve Easton)
| showed me
| > > > how
| > > > > > to add 2 numeric variables from an html form.
| > > > > >
| > > > > > <input type="text" name="amt" size="5"
| onblur="this.form.Total.value =
| > > > > > parseInt(this.form.constant.value) +
| parseInt(this.form.amt.value)"
| > > > > > maxlength="5">
| > > > > > <input type="hidden" name="amt2" onblur="this.form.amt2.value =
| > > > > > this.form.Total.value" >
| > > > > >
| > > > > > But now I'd like to concatenate two strings, one, user input, the
| > > other
| > > > a
| > > > > > constant.
| > > > > >
| > > > > > Any help is greatly appreciated.
| > > > > >
| > > > > > Thanks
| > > > > >
| > > > > > Russell
| > > > > >
| > > > > >
| > > > > >
| > > > > >
| > > > > > | > > > > > > You would have to learn to write JavaScript to accomplish
| > > client-side
| > > > in
| > > > > > the browser or learn
| > > > > > > server-side scripting (ASP, ASP.net, PHP, etc.) to accomplish
| > > > server-side.
| > > > > > >
| > > > > > > --
| > > > > > > ==============================================
| > > > > > > Thomas A. Rowe (Microsoft MVP - FrontPage)
| > > > > > > ==============================================
| > > > > > > If you feel your current issue is a results of installing
| > > > > > > a Service Pack or security update, please contact
| > > > > > > Microsoft Product Support Services:
| > > > > > > http://support.microsoft.com
| > > > > > > If the problem can be shown to have been caused by a
| > > > > > > security update, then there is usually no charge for the call.
| > > > > > > ==============================================
| > > > > > >
| > > > > > | > > > > > > > ooops,
| > > > > > > >
| > > > > > > > In HTML I have a form with user input (variable1) I would
| like to
| > > > > > > > concatenate this with either variable2 or a constant.
| > > > > > > >
| > > > > > > > Thanks,
| > > > > > > >
| > > > > > > > Russell
| > > > > > > >
| > > > > > > >
| > > > > > > > | > > > > > > >> What language??
| > > > > > > >>
| > > > > > > >> --
| > > > > > > >> Steve Easton
| > > > > > > >> Microsoft MVP FrontPage
| > > > > > > >> 95isalive
| > > > > > > >> This site is best viewed............
| > > > > > > >> .......................with a computer
| > > > > > > >>
| > > > > > > >> | > > > > > > >> > Hello,
| > > > > > > >> >
| > > > > > > >> > I would like to concatenate user input (variable1) with a
| > > > constant
| > > > > > or
| > > > > > > >> > variable2. Any help would be appreciated.
| > > > > > > >> >
| > > > > > > >> > Russell
| > > > > > > >> >
| > > > > > > >> >
| > > > > > > >>
| > > > > > > >>
| > > > > > > >
| > > > > > > >
| > > > > > >
| > > > > > >
| > > > > >
| > > > > >
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
 
You don't understand
The values used in Form Fields do not display on the page or affect the size of the dropdown
- they can be anything you want
All that affects the dropdown size or display to the user is what is between the <option> </option>tags

<option value="I can have a very long value in here like Fabric Color is White">White</option>
The dropdown will just show the word "White" and will be no wider than the word "White"

--



| Thanks for the lesson and your opinion. I agree, however the form and page
| do not look as nice with the added width of "fabric color", flower color",
| etc added to the drop down list.


| The onblur is a javascript event that can trigger an action when an object on the page loses focus
| - means when the form field (in your example the form field name="amt") loses focus (use leave the field) do something, and the do
| some thing is:
| Add to the field named "Total" the value of field named "constant" and the value of the field named "amt"
|
| Since it is doing math the values of "constant" and "amt" are being parsed to integer first
| - that is the reason they are surrounded by parseInt()
|
| In your new case you are trying to concatenate strings, not numbers so you would not use parseInt
|
| You could also use an event at each unique dropdown
| But you would use the onchange event (instead of the onblur event)
| - since the user is not typing anything but selecting a dropdown option (changing a selection) from a form field named FabricColor
| (the below <select> opening tag all on 1 line)
|
| <select size="1" name="FabricColor" onchange="this.form.FabricColor.value = 'Fabric Colour - ' +
| this.form.FabricColor.options.selectedIndex].value";>
| <option value="White">White</option>
| <option value="Black">Black</option>
| <option value="Beige">Beige</option>
| </select>
|
|
| IMHO
| Frankly a lot of unnecessary javascript when you could just edit the form field values to include the desired full values as say:
|
| <select size="1" name="FabricColor">
| <option value="Fabric Color - White">White</option>
| <option value="Fabric Color - Black">Black</option>
| <option value="Fabric Color - Beige">Beige</option>
| </select>
| <select size="1" name="LaceColor">
| <option value="Lace Color - White">White</option>
| <option value="Lace Color - Black">Black</option>
| <option value="Lace Color - Beige">Beige</option>
| </select>
| etc.
| --
|
| _____________________________________________
| SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| "Warning - Using the F1 Key will not break anything!" (-;
| To find the best Newsgroup for FrontPage support see:
| http://www.net-sites.com/sitebuilder/newsgroups.asp
| _____________________________________________
|
|
|| Thanks Steve,
||
|| Was my error , I didn't include all the info on what I was doing.
||
|| I have another question though about the code Jon gave me. On another site,
|| you or another MVP helped with some Java Sc ript math. That code was :
|| <input type="hidden" name="Total" value="0">
|| <input type="hidden" name="constant" value="20">
|| <input type="text" name="amt" size="5" onblur="this.form.Total.value =
|| parseInt(this.form.constant.value) + parseInt(this.form.amt.value)"
|| maxlength="5">
|| <input type="hidden" name="amt2" onblur="this.form.amt2.value =
|| this.form.Total.value" >
||
|| This works fine for adding a user's numeric input value to a constant.
|| There is no java script tag. How come we need it in the example Jon gave me
|| today but not in this one? And sint it possible to concatenate the same
|| way?
||
|| Thanks again,
||
|| Russell
||
||
||
||
||
|| || > I didn't know / you didn't say you were using an drop down select.
|| > Jon Spivey has given you the correct answer.
|| >
|| > --
|| > Steve Easton
|| > Microsoft MVP FrontPage
|| > 95isalive
|| > This site is best viewed............
|| > .......................with a computer
|| >
|| > || > > Well Steve, Thanks, I've been trying to no avail. Perhaps I should be
|| more
|| > > specific.
|| > >
|| > > I am sending data to a shopping cart. I need to have a user input fabric
|| > > colors and other variables. The shopping cart will display ONLY a list
|| of
|| > > the user inputs,ie blue, green, etc. It will NOT display what the
|| variable
|| > > refers to (fabric color, border color). So I would like to concatenate a
|| > > constant (Fabric color) with the users input called custom2.
|| > >
|| > >
|| > > I have the following:
|| > > <INPUT TYPE="HIDDEN" NAME="variable1" VALUE="Fabric color">
|| > > <select size="1" name="custom2">
|| > > <option value="White">White</option>
|| > > <option value="Black">Black</option>
|| > > <option value="Beige">Beige</option>
|| > > </select>
|| > > <input TYPE="submit" NAME="add" VALUE="Add to Cart">
|| > > </form>
|| > >
|| > >
|| > > I would appreciate it if you could be more specific as to what I need to
|| do
|| > > to accomplish my goals.
|| > >
|| > > Thank You,
|| > >
|| > > Russell
|| > >
|| > >
|| > >
|| > >
|| > > || > > > TY Steve, much appreciated. I will try this and report back.
|| > > >
|| > > > Russell
|| > > >
|| > > >
|| > > > || > > > > Assuming javascript:
|| > > > > Make sure the variables are global, which means they are declared
|| after
|| > > > the opening script
|| > > > > tag but before any functions.
|| > > > >
|| > > > > <script type= "text/javascript">
|| > > > > var value1
|| > > > > var value2
|| > > > > var value3
|| > > > > function myfunction(){
|| > > > > value3 = 'value1'+'value2';
|| > > > > }
|| > > > > </script>
|| > > > >
|| > > > > another way to concatenate strings inside the function is:
|| > > > >
|| > > > > value3 = 'value1'\n;
|| > > > > value3+='value2';
|| > > > >
|| > > > > --
|| > > > > Steve Easton
|| > > > > Microsoft MVP FrontPage
|| > > > > 95isalive
|| > > > > This site is best viewed............
|| > > > > .......................with a computer
|| > > > >
|| > > > > || > > > > > Thanks, but luckily they're are some MVP's that are willing to
|| show
|| > > > someone
|| > > > > > like me how to do this.
|| > > > > > I don't remember who helped but someone (maybe Steve Easton)
|| showed me
|| > > > how
|| > > > > > to add 2 numeric variables from an html form.
|| > > > > >
|| > > > > > <input type="text" name="amt" size="5"
|| onblur="this.form.Total.value =
|| > > > > > parseInt(this.form.constant.value) +
|| parseInt(this.form.amt.value)"
|| > > > > > maxlength="5">
|| > > > > > <input type="hidden" name="amt2" onblur="this.form.amt2.value =
|| > > > > > this.form.Total.value" >
|| > > > > >
|| > > > > > But now I'd like to concatenate two strings, one, user input, the
|| > > other
|| > > > a
|| > > > > > constant.
|| > > > > >
|| > > > > > Any help is greatly appreciated.
|| > > > > >
|| > > > > > Thanks
|| > > > > >
|| > > > > > Russell
|| > > > > >
|| > > > > >
|| > > > > >
|| > > > > >
|| > > > > > || > > > > > > You would have to learn to write JavaScript to accomplish
|| > > client-side
|| > > > in
|| > > > > > the browser or learn
|| > > > > > > server-side scripting (ASP, ASP.net, PHP, etc.) to accomplish
|| > > > server-side.
|| > > > > > >
|| > > > > > > --
|| > > > > > > ==============================================
|| > > > > > > Thomas A. Rowe (Microsoft MVP - FrontPage)
|| > > > > > > ==============================================
|| > > > > > > If you feel your current issue is a results of installing
|| > > > > > > a Service Pack or security update, please contact
|| > > > > > > Microsoft Product Support Services:
|| > > > > > > http://support.microsoft.com
|| > > > > > > If the problem can be shown to have been caused by a
|| > > > > > > security update, then there is usually no charge for the call.
|| > > > > > > ==============================================
|| > > > > > >
|| > > > > > || > > > > > > > ooops,
|| > > > > > > >
|| > > > > > > > In HTML I have a form with user input (variable1) I would
|| like to
|| > > > > > > > concatenate this with either variable2 or a constant.
|| > > > > > > >
|| > > > > > > > Thanks,
|| > > > > > > >
|| > > > > > > > Russell
|| > > > > > > >
|| > > > > > > >
|| > > > > > > > || > > > > > > >> What language??
|| > > > > > > >>
|| > > > > > > >> --
|| > > > > > > >> Steve Easton
|| > > > > > > >> Microsoft MVP FrontPage
|| > > > > > > >> 95isalive
|| > > > > > > >> This site is best viewed............
|| > > > > > > >> .......................with a computer
|| > > > > > > >>
|| > > > > > > >> || > > > > > > >> > Hello,
|| > > > > > > >> >
|| > > > > > > >> > I would like to concatenate user input (variable1) with a
|| > > > constant
|| > > > > > or
|| > > > > > > >> > variable2. Any help would be appreciated.
|| > > > > > > >> >
|| > > > > > > >> > Russell
|| > > > > > > >> >
|| > > > > > > >> >
|| > > > > > > >>
|| > > > > > > >>
|| > > > > > > >
|| > > > > > > >
|| > > > > > >
|| > > > > > >
|| > > > > >
|| > > > > >
|| > > > >
|| > > > >
|| > > >
|| > > >
|| > >
|| > >
|| >
|| >
||
||
|
|
 
Your right , I didn't understand. Thank you for clearing it up for me. Much
appreciated. I use fp all the time but know very little HTML. Good thing I
have the MVP's!!!.

Thanks again.

Russell


Stefan B Rusynko said:
You don't understand
The values used in Form Fields do not display on the page or affect the size of the dropdown
- they can be anything you want
All that affects the dropdown size or display to the user is what is
between the said:
<option value="I can have a very long value in here like Fabric Color is
White">White said:
The dropdown will just show the word "White" and will be no wider than the word "White"

--



| Thanks for the lesson and your opinion. I agree, however the form and page
| do not look as nice with the added width of "fabric color", flower color",
| etc added to the drop down list.


| The onblur is a javascript event that can trigger an action when an object on the page loses focus
| - means when the form field (in your example the form field name="amt")
loses focus (use leave the field) do something, and the do
| some thing is:
| Add to the field named "Total" the value of field named "constant" and
the value of the field named "amt"
|
| Since it is doing math the values of "constant" and "amt" are being parsed to integer first
| - that is the reason they are surrounded by parseInt()
|
| In your new case you are trying to concatenate strings, not numbers so you would not use parseInt
|
| You could also use an event at each unique dropdown
| But you would use the onchange event (instead of the onblur event)
| - since the user is not typing anything but selecting a dropdown option
(changing a selection) from a form field named FabricColor
| (the below <select> opening tag all on 1 line)
|
| <select size="1" name="FabricColor"
onchange="this.form.FabricColor.value = 'Fabric Colour - ' +
| this.form.FabricColor.options.selectedIndex].value";>
| <option value="White">White</option>
| <option value="Black">Black</option>
| <option value="Beige">Beige</option>
| </select>
|
|
| IMHO
| Frankly a lot of unnecessary javascript when you could just edit the
form field values to include the desired full values as say:
|
| <select size="1" name="FabricColor">
| <option value="Fabric Color - White">White</option>
| <option value="Fabric Color - Black">Black</option>
| <option value="Fabric Color - Beige">Beige</option>
| </select>
| <select size="1" name="LaceColor">
| <option value="Lace Color - White">White</option>
| <option value="Lace Color - Black">Black</option>
| <option value="Lace Color - Beige">Beige</option>
| </select>
| etc.
| --
|
| _____________________________________________
| SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| "Warning - Using the F1 Key will not break anything!" (-;
| To find the best Newsgroup for FrontPage support see:
| http://www.net-sites.com/sitebuilder/newsgroups.asp
| _____________________________________________
|
|
|| Thanks Steve,
||
|| Was my error , I didn't include all the info on what I was doing.
||
|| I have another question though about the code Jon gave me. On another site,
|| you or another MVP helped with some Java Sc ript math. That code was :
|| <input type="hidden" name="Total" value="0">
|| <input type="hidden" name="constant" value="20">
|| <input type="text" name="amt" size="5" onblur="this.form.Total.value =
|| parseInt(this.form.constant.value) + parseInt(this.form.amt.value)"
|| maxlength="5">
|| <input type="hidden" name="amt2" onblur="this.form.amt2.value =
|| this.form.Total.value" >
||
|| This works fine for adding a user's numeric input value to a constant.
|| There is no java script tag. How come we need it in the example Jon gave me
|| today but not in this one? And sint it possible to concatenate the same
|| way?
||
|| Thanks again,
||
|| Russell
||
||
||
||
||
|| || > I didn't know / you didn't say you were using an drop down select.
|| > Jon Spivey has given you the correct answer.
|| >
|| > --
|| > Steve Easton
|| > Microsoft MVP FrontPage
|| > 95isalive
|| > This site is best viewed............
|| > .......................with a computer
|| >
|| > || > > Well Steve, Thanks, I've been trying to no avail. Perhaps I should be
|| more
|| > > specific.
|| > >
|| > > I am sending data to a shopping cart. I need to have a user input fabric
|| > > colors and other variables. The shopping cart will display ONLY a list
|| of
|| > > the user inputs,ie blue, green, etc. It will NOT display what the
|| variable
|| > > refers to (fabric color, border color). So I would like to concatenate a
|| > > constant (Fabric color) with the users input called custom2.
|| > >
|| > >
|| > > I have the following:
|| > > <INPUT TYPE="HIDDEN" NAME="variable1" VALUE="Fabric color">
|| > > <select size="1" name="custom2">
|| > > <option value="White">White</option>
|| > > <option value="Black">Black</option>
|| > > <option value="Beige">Beige</option>
|| > > </select>
|| > > <input TYPE="submit" NAME="add" VALUE="Add to Cart">
|| > > </form>
|| > >
|| > >
|| > > I would appreciate it if you could be more specific as to what I need to
|| do
|| > > to accomplish my goals.
|| > >
|| > > Thank You,
|| > >
|| > > Russell
|| > >
|| > >
|| > >
|| > >
|| > > || > > > TY Steve, much appreciated. I will try this and report back.
|| > > >
|| > > > Russell
|| > > >
|| > > >
|| > > > || > > > > Assuming javascript:
|| > > > > Make sure the variables are global, which means they are declared
|| after
|| > > > the opening script
|| > > > > tag but before any functions.
|| > > > >
|| > > > > <script type= "text/javascript">
|| > > > > var value1
|| > > > > var value2
|| > > > > var value3
|| > > > > function myfunction(){
|| > > > > value3 = 'value1'+'value2';
|| > > > > }
|| > > > > </script>
|| > > > >
|| > > > > another way to concatenate strings inside the function is:
|| > > > >
|| > > > > value3 = 'value1'\n;
|| > > > > value3+='value2';
|| > > > >
|| > > > > --
|| > > > > Steve Easton
|| > > > > Microsoft MVP FrontPage
|| > > > > 95isalive
|| > > > > This site is best viewed............
|| > > > > .......................with a computer
|| > > > >
|| > > > > || > > > > > Thanks, but luckily they're are some MVP's that are willing to
|| show
|| > > > someone
|| > > > > > like me how to do this.
|| > > > > > I don't remember who helped but someone (maybe Steve Easton)
|| showed me
|| > > > how
|| > > > > > to add 2 numeric variables from an html form.
|| > > > > >
|| > > > > > <input type="text" name="amt" size="5"
|| onblur="this.form.Total.value =
|| > > > > > parseInt(this.form.constant.value) +
|| parseInt(this.form.amt.value)"
|| > > > > > maxlength="5">
|| > > > > > <input type="hidden" name="amt2" onblur="this.form.amt2.value =
|| > > > > > this.form.Total.value" >
|| > > > > >
|| > > > > > But now I'd like to concatenate two strings, one, user input, the
|| > > other
|| > > > a
|| > > > > > constant.
|| > > > > >
|| > > > > > Any help is greatly appreciated.
|| > > > > >
|| > > > > > Thanks
|| > > > > >
|| > > > > > Russell
|| > > > > >
|| > > > > >
|| > > > > >
|| > > > > >
|| > > > > > || > > > > > > You would have to learn to write JavaScript to accomplish
|| > > client-side
|| > > > in
|| > > > > > the browser or learn
|| > > > > > > server-side scripting (ASP, ASP.net, PHP, etc.) to accomplish
|| > > > server-side.
|| > > > > > >
|| > > > > > > --
|| > > > > > > ==============================================
|| > > > > > > Thomas A. Rowe (Microsoft MVP - FrontPage)
|| > > > > > > ==============================================
|| > > > > > > If you feel your current issue is a results of installing
|| > > > > > > a Service Pack or security update, please contact
|| > > > > > > Microsoft Product Support Services:
|| > > > > > > http://support.microsoft.com
|| > > > > > > If the problem can be shown to have been caused by a
|| > > > > > > security update, then there is usually no charge for the call.
|| > > > > > > ==============================================
|| > > > > > >
|| > > > > > || > > > > > > > ooops,
|| > > > > > > >
|| > > > > > > > In HTML I have a form with user input (variable1) I would
|| like to
|| > > > > > > > concatenate this with either variable2 or a constant.
|| > > > > > > >
|| > > > > > > > Thanks,
|| > > > > > > >
|| > > > > > > > Russell
|| > > > > > > >
|| > > > > > > >
|| > > > > > > > || > > > > > > >> What language??
|| > > > > > > >>
|| > > > > > > >> --
|| > > > > > > >> Steve Easton
|| > > > > > > >> Microsoft MVP FrontPage
|| > > > > > > >> 95isalive
|| > > > > > > >> This site is best viewed............
|| > > > > > > >> .......................with a computer
|| > > > > > > >>
|| > > > > > > >> || > > > > > > >> > Hello,
|| > > > > > > >> >
|| > > > > > > >> > I would like to concatenate user input (variable1) with a
|| > > > constant
|| > > > > > or
|| > > > > > > >> > variable2. Any help would be appreciated.
|| > > > > > > >> >
|| > > > > > > >> > Russell
|| > > > > > > >> >
|| > > > > > > >> >
|| > > > > > > >>
|| > > > > > > >>
|| > > > > > > >
|| > > > > > > >
|| > > > > > >
|| > > > > > >
|| > > > > >
|| > > > > >
|| > > > >
|| > > > >
|| > > >
|| > > >
|| > >
|| > >
|| >
|| >
||
||
|
|
 
hmm... HTML= HyperText Markup Language. I know you mean script language,
Thomas. I just couldnt' resist. :)

...PC
 
Back
Top