HighDots Forums  

Newbie: Copy value from field to another in form?

HTML Writing HTML for the Web (comp.infosystems.www.authoring.html)


Discuss Newbie: Copy value from field to another in form? in the HTML forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Lee Falataco
 
Posts: n/a

Default Newbie: Copy value from field to another in form? - 06-22-2004 , 03:22 PM






I've looked everywhere for the answer to this and can't find it. Is
it possible to automatically fill in the value of a field in a form
once a value is entered in another field?

For example, I want to have the same date entered in "Start Date" pop
up into "End Date" automatically with the option of letting the user
change it if needed.

TIA!

Here's my code:

<table width="90%" border="0">

<tr>

<td width="18%" height="25" class="pgtext"><div
align="right" class="pgtext"><strong>Event:</strong></div></td>
<td colspan="4"> <span class="pgtext">
<input name="txtEvent" type="text" id="txtEvent2"
size="50" maxlength="70">

</span></td>
</tr>

<tr>

<td class="pgtext"><div align="right"
class="pgtext"><strong>Start Date:</strong></div></td>
<td width="14%"> <span class="pgtext">
<input name="varStartDate" type="text" id="varStartDate"
onBlur="MM_validateForm('txtEvent2','','R','varSta rtDate','','R');return
document.MM_returnValue" size="10" maxlength="10">


</span></td>
<td width="16%"><span class="pgtext">
<input name="StartDateCal" type="button"
id="StartDateCal" onClick="KW_doCalendar('txtStartDate',0)"
value="Calendar">
</span></td>
<td width="26%" class="pgtext"> <div align="right"
class="pgtext"><strong>Start
Time:</strong></div></td>
<td width="26%"> <span class="pgtext">
<input name="txtStartTime" type="text"
id="txtStartTime2" size="10" maxlength="10">
</span></td>
</tr>

<tr>

<td class="pgtext"><div align="right"
class="pgtext"><strong>End Date:</strong></div></td>
<td colspan="2"> <span class="pgtext">
<input name="txtEndDate" type="text" id="txtEndDate"
size="10" maxlength="10">


<input name="EndDateCalendar" type="button"
id="EndDateCalendar" onClick="KW_doCalendar('txtEndDate',0)"
value="Calendar">

<strong> </strong></span></td>
<td class="pgtext"> <div align="right"
class="pgtext"><strong>End Time:</strong></div></td>
<td> <span class="pgtext">
<input name="txtEndTime" type="text" id="txtEndTime2"
size="10" maxlength="10">
</span></td>
</tr>

<tr>

<td class="pgtext"><div align="right"
class="pgtext"><strong>Location:</strong></div></td>
<td colspan="4"> <span class="pgtext">
<select name="txtLocation" id="select2">

<option value="Location" <%If (Not
isNull((rs_location.Fields.Item("location").Value) )) Then If
("Location" = CStr((rs_location.Fields.Item("location").Value))) Then
Response.Write("SELECTED") : Response.Write("")%>>Location</option>

<%
While (NOT rs_location.EOF)
%>

<option
value="<%=(rs_location.Fields.Item("location").Val ue)%>" <%If (Not
isNull((rs_location.Fields.Item("location").Value) )) Then If
(CStr(rs_location.Fields.Item("location").Value) =
CStr((rs_location.Fields.Item("location").Value))) Then
Response.Write("SELECTED") : Response.Write("")%>
Quote:
%=(rs_location.Fields.Item("location").Value)%></option
<%
rs_location.MoveNext()
Wend
If (rs_location.CursorType > 0) Then
rs_location.MoveFirst
Else
rs_location.Requery
End If
%>

</select>
</span></td>
</tr>

<tr>

<td class="pgtext"><div align="right"
class="pgtext"><strong>Group:</strong></div></td>
<td colspan="4"> <span class="pgtext">
<select name="txtGroup" id="txtGroup">

<option value="All" <%If (Not
isNull((rs_group.Fields.Item("evt_grp").Value))) Then If ("All" =
CStr((rs_group.Fields.Item("evt_grp").Value))) Then
Response.Write("SELECTED") : Response.Write("")%>>All</option>

<%
While (NOT rs_group.EOF)
%>

<option
value="<%=(rs_group.Fields.Item("evt_grp").Value)% >" <%If (Not
isNull((rs_group.Fields.Item("evt_grp").Value))) Then If
(CStr(rs_group.Fields.Item("evt_grp").Value) =
CStr((rs_group.Fields.Item("evt_grp").Value))) Then
Response.Write("SELECTED") : Response.Write("")%>
Quote:
%=(rs_group.Fields.Item("evt_grp").Value)%></option
<%
rs_group.MoveNext()
Wend
If (rs_group.CursorType > 0) Then
rs_group.MoveFirst
Else
rs_group.Requery
End If
%>

</select>
</span></td>
</tr>

<tr>

<td class="pgtext"><div align="right"
class="pgtext"><strong>Who can attend?</strong></div></td>
<td colspan="4"> <span class="pgtext">
<input name="txtAttend" type="text" id="txtAttend2"
size="30" maxlength="30">
</span></td>
</tr>

<tr>

<td class="pgtext"><div align="right"
class="pgtext"><strong>Type:</strong></div></td>
<td colspan="4" class="pgtext">
<select name="txtType" id="select3">

<option value="Location" <%If (Not
isNull((rs_types.Fields.Item("type").Value))) Then If ("Location" =
CStr((rs_types.Fields.Item("type").Value))) Then
Response.Write("SELECTED") : Response.Write("")%>>Location</option>

<%
While (NOT rs_types.EOF)
%>

<option
value="<%=(rs_types.Fields.Item("type").Value)%>" <%If (Not
isNull((rs_types.Fields.Item("type").Value))) Then If
(CStr(rs_types.Fields.Item("type").Value) =
CStr((rs_types.Fields.Item("type").Value))) Then
Response.Write("SELECTED") : Response.Write("")%>
Quote:
%=(rs_types.Fields.Item("type").Value)%></option
<%
rs_types.MoveNext()
Wend
If (rs_types.CursorType > 0) Then
rs_types.MoveFirst
Else
rs_types.Requery
End If
%>

</select>
</td>
</tr>

<tr>

<td class="pgtext"><div align="right"
class="pgtext"><strong>Contact:</strong></div></td>
<td colspan="4"> <span class="pgtext">
<input name="txtContact" type="text" id="txtContact2"
size="30" maxlength="50">
</span></td>
</tr>

<tr>

<td valign="top" class="pgtext"><div align="right"
class="pgtext"><strong>Description:</strong></div></td>
<td colspan="4" class="pgtext">
<textarea name="txtDesc" cols="45" rows="4"
id="txtDesc"></textarea>
</td>
</tr>

<tr>

<td colspan="5">&nbsp;</td>
</tr>

</table>


Reply With Quote
  #2  
Old   
Dr John Stockton
 
Posts: n/a

Default Newbie: Copy value from field to another in form? - 06-23-2004 , 08:17 AM






JRS: In article <667ce401.0406221122.56699cdd (AT) posting (DOT) google.com>, seen
in news:comp.infosystems.www.authoring.html, Lee Falataco
<leekaye (AT) yahoo (DOT) com> posted at Tue, 22 Jun 2004 12:22:54 :

Quote:
I've looked everywhere for the answer to this and can't find it. Is
it possible to automatically fill in the value of a field in a form
once a value is entered in another field?
Yes, see sig below. But there will be no need to re-post all that over-
indented and badly-wrapped code.

The following, tested, may be the simplest demonstration of the
possibility; but maybe does not show the best coding practice.
"B.value=A.value*2" also works.

<input ID=A onChange="B.value=A.value*2"></input>
<input ID=B></input>

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.