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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox Value

Status
Not open for further replies.

Dhagaxtuur

Technical User
Apr 15, 2003
47
CA
I have the following listbox incrementing date by day. It's part of a form processed by another file. When I select value and try to update a field in a database, it saves selected value concatinating with previous value. For example if I had 1/2/2003 and try to update to 1/4/2003 result is 1/3/20031/4/2003. I know the problem is associated with the loop. [for day=0 to 90]. How can I save only selected option?.

<select name=&quot;shipdate&quot;>
<%
dim day, selectionDate
for day = 0 to 90
currDate =Dateadd(&quot;D&quot;,day,Date)
%>
<option value=&quot;<%=selectionDate%>&quot;><%=selectionDate%>
<%next%>
</select>
 
Hey,

looking over your code I feel like something is missing. Maybe it's too early for me but I can't seem to see where the variable &quot;selectionDate&quot; is set. I see the Dim but I don't see it set. Probably not the main problem, otherwise all dates would come out blank but without seeing how the variable is set it's hard to tell why it would hold 2 dates.

I tried this code based on yours and it worked:
Code:
<select name=&quot;shipdate&quot;>
<%
dim day, selectionDate
for day = 0 to 90 
currDate =Dateadd(&quot;D&quot;,day,Date)
%>
<option value=&quot;<%=currDate%>&quot;><%=currDate%>
<%next%>
</select>

I hope that helps.


Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Not sure what you're trying to do. This will populate your select box and the date that you select will be posted along with your form.
<select name=&quot;shipdate&quot;>
<%
dim day, selectionDate
for day = 0 to 90
currDate =Dateadd(&quot;D&quot;,day,Date)
%>
<option value=&quot;<%=currDate%>&quot;><%=currDate%></option>
<%next%>
</select>
 
Thank you tlhawkins and Veep. It was working as it's but what I was looking at was another output.
 
well,

The output from the examples that Veep and I gave you shouldn't show 2 dates. They should only show one. I think we both assumed that whatever the problem was must have been in the code you weren't showing.

So, how is the output from the methods we showed you? is it still showing double dates? If so it must be in the recieving form.

If you're still having trouble show us the Update SQL, maybe it's something in there.

You could also try writing the SQL to the screen before sending to the database, that always seems to help track down SQL and DB problems.


Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top