| Author |
Re: concatenate two fields
|
|
| rilkesf 2005-09-13, 4:15 am |
| Try this. It should work, if I'm understanding what you want correctly.
<script language="javascript" type="text/javascript">
<!--
function putDateInHiddenField() {
var text = document.myform.mytext;
var hidden = document.myform.myhidden;
var d = document.myform.myselect;
var drop = d.options[d.selectedIndex];
hidden.value = "";
hidden.value += text.value + " " + drop.value;
}
-->
</script>
<body>
<form name="myform" >
<input type="text" name="mytext" />
<select name="myselect">
<option value="option1">option 1</option>
<option value="option2">option 2</option>
<option value="option3">option 3</option>
</select>
<input type="text" name="myhidden" />
<input type="button" value="Concatenate" onclick="putDateInHiddenField();" />
</form>
</body>
I've left the hidden field visible so that you can see it working, but you can
change that easily enough.
| |
| Alejandro 2005-09-15, 7:19 pm |
| This worked great ! Thanks !
Now I have another task .. I still have the same text box and the time drop
down menu, I have the date in my DB with date + time.
How can I separate it so that in the text box I only get the date and in the
drop down I only get the time ?
A
"rilkesf" <webforumsuser@macromedia.com> wrote in message
news:dg5hs5$ac2$1@forums.macromedia.com...
> Try this. It should work, if I'm understanding what you want correctly.
>
> <script language="javascript" type="text/javascript">
> <!--
> function putDateInHiddenField() {
> var text = document.myform.mytext;
> var hidden = document.myform.myhidden;
> var d = document.myform.myselect;
> var drop = d.options[d.selectedIndex];
> hidden.value = "";
> hidden.value += text.value + " " + drop.value;
> }
> -->
> </script>
>
> <body>
> <form name="myform" >
> <input type="text" name="mytext" />
> <select name="myselect">
> <option value="option1">option 1</option>
> <option value="option2">option 2</option>
> <option value="option3">option 3</option>
> </select>
> <input type="text" name="myhidden" />
> <input type="button" value="Concatenate"
> onclick="putDateInHiddenField();" />
> </form>
> </body>
>
> I've left the hidden field visible so that you can see it working, but you
> can
> change that easily enough.
>
>
| |
| rilkesf 2005-09-16, 7:34 pm |
| If you're going to take the date and time from your form and then re-insert it
into your form, it would probably be easier to just leave them as separate
fields. Is there any reason you need to put them together?
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |