Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string manipulation

Status
Not open for further replies.

mary555

Programmer
Nov 9, 2005
185
CA
i have a text field on my asp page and it gets its value from a popup calendar. i need to separate the values so that they can be used with the dateserial function. in the text field it appears as 01 24 2005 so i am going to need to have 3 separate text fields and have the month in one, the day in another and the year in the third. im not really sure how to do this...thanks
 
Do you have any relevant code showing what you are trying to do? We're more than happy to help but you need to show us what you're doing so that we can help...

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
If you are using VBScript for your ASP then you might use functions like Mid() and InStr().

If you always get the string back in that exact format you could perhaps use the Replace() function to substitute a slash or dash for every space character in the string. Then you could pass the string to the CDate() function instead of DateSerial()
 
thanks...i decided to use the Split function and it works...I have:



<% Dim edate1
edate1=Request.Form("edate1")
%>

<input type="text" name="edate1" id="edate1" size="15" valign="top" value='<%response.write edate1%>'>

<img src="file:///C:/Inetpub/ name="ChoseDate2" id="ChoseDate" IndexVal="edate1" onclick="vbscript:CALL GetDate(Me)" onchange="frmL.submit()" WIDTH="35" HEIGHT="33"> </font>


<table width="97" align="center"><font color="white"></font><tr>
<td align="center">
<font color="#FFFFFF">HH</font></td>
<td width="41" align="center">
<font color="#FFFFFF">MM</font></td></tr></font>
</br><font size="1">
<tr>
<td align="center"><input type="text" name="TimeH2" size="3" value="<%Response.Write TimeH2%>" tabindex="9"></td>

<td align="center"><input type="text" name="TimeM2" size="3" value="<%Response.Write TimeM2%>" tabindex="10"></td>

<td><input type="button" onclick="frmL.submit" value="continue"><p align="center"></td>

</tr></table>

<p align="center">
<input type="text" name="EDate" value="<%if not ValComboLost="" Then Response.Write DateSerial(Year2,Month2,Day2)&" " &TimeSerial(TimeH2,TimeM2,00) end if%>">


<% Dim edate2
edate2=Request.Form("edate2")
%>

<%
MyVar2 = edate1
MyArray2 = Split(MyVar2," ")
response.write MyArray2(0)
response.write " "
response.write MyArray2(1)
response.write " "
response.write MyArray2(2)
%>

<input type="hidden" name="Month2" id="Month2" size="15" valign="top" value='<%response.write MyArray2(0)%>'>


<input type="hidden" name="Day2" id="Day2" size="15" valign="top" value='<%response.write MyArray2(1)%>'>



<input type="hidden" name="Year2" id="Year2" size="15" valign="top" value='<%response.write MyArray2(2)%>'>

and at the top i have :
Month2=Request.Form("Month2")
Day2=Request.Form("Day2")
Year2=Request.Form("Year2")



I would like to avoid having the user have to press the continue button to get the right value in the EDate field. Right after the user enters this information they have to press a button to do some more calculations and i need these calculations to use the date value that was chosen. any suggestions?
 
Maybe use client-side JavaScript to do the work when the button is clicked?
 
i am but i don' twant the user to have to press a button to do it...what if they forget?
 
Maybe write the logic into a client-side function that is triggered by the HTML form's onSubmit event?
 
can u explain that more please, im not relaly sure how to do that...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top