Forums

ASP

This topic is locked

Adding Date (Dropdown->Hidden Field->Database)

Posted 23 Mar 2006 10:12:58
1
has voted
23 Mar 2006 10:12:58 dako cada posted:
Ok I know I suck at this but can you guys help with this I really need it for my training course

Its a Blank Page with 3 Dropdowns, Month,Day,Year Respectively
1 Hidden Field (This is meant to sture the full Date)
1 text box (just shows the value taht is the same as whats to be put in the hidden field)
and a submit button

From what I can tell The dropdown puts the values in the Hidden Field just fine the problem is (me the dumbass speaking) that the form is submitted before the value is set.

This is probably a bad way of doing this sort of form but can you guys help fix it or guide me on how to make a working form for this task

Any help is greatly appreciated

Tnx ion advance

---------------------------------------------------------------------------------------------------------------------------------------

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" debug="true" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>

<script runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
If IsPostBack Then
txtFullDate.text = ddlMonth.SelectedItem.value &"/"& ddlDay.SelectedItem.value &"/"& ddlYear.SelectedItem.value
End If
End Sub
</script>

&lt;MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert
runat="server"
CommandText='&lt;%# "INSERT INTO Test4Date (TestDate) VALUES (?)" %&gt;'
ConnectionString='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Company" %&gt;'
DatabaseType='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_Company" %&gt;'
Expression='&lt;%# Request.Form("MM_Insert" = "form1" %&gt;'
CreateDataSet="false"
Debug="true"
&gt;
&lt;Parameters&gt;
&lt;Parameter Name="@TestDate" Value='&lt;%# IIf((Request.Form("TestDate" &lt;&gt; Nothing), Request.Form("TestDate", "" %&gt;' Type="Date" /&gt;
&lt;/Parameters&gt;
&lt;/MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert&gt;
&lt;MMataSet
id="DSDate"
runat="Server"
IsStoredProcedure="false"
ConnectionString='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Company" %&gt;'
DatabaseType='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_Company" %&gt;'
CommandText='&lt;%# "SELECT * FROM Test4Date" %&gt;'
Debug="true"
&gt;&lt;/MMataSet&gt;
&lt;MM<img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle>ageBind runat="server" PostBackBind="true" /&gt;

&lt;head&gt;
&lt;title&gt;Add New Sell Offer&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form method="post" name="form1" runat="server"&gt;
&lt;aspropDownList ID="ddlMonth" OnSelectedIndexChanged="Page_Load" runat="server"&gt;
&lt;asp:ListItem Value="01"&gt;Jan&lt;/asp:ListItem&gt;
&lt;asp:ListItem Value="02"&gt;Feb&lt;/asp:ListItem&gt;
&lt;asp:ListItem Value="03"&gt;Mar&lt;/asp:ListItem&gt;
&lt;/aspropDownList&gt;
&lt;aspropDownList ID="ddlDay" OnSelectedIndexChanged="Page_Load" runat="server"&gt;
&lt;asp:ListItem Value="01"&gt;01&lt;/asp:ListItem&gt;
&lt;asp:ListItem Value="02"&gt;02&lt;/asp:ListItem&gt;
&lt;asp:ListItem Value="03"&gt;03&lt;/asp:ListItem&gt;
&lt;/aspropDownList&gt;
&lt;aspropDownList ID="ddlYear" OnSelectedIndexChanged="Page_Load" runat="server"&gt;
&lt;asp:ListItem value="2006"&gt;2006&lt;/asp:ListItem&gt;
&lt;asp:ListItem value="2007"&gt;2007&lt;/asp:ListItem&gt;
&lt;asp:ListItem value="2008"&gt;2008&lt;/asp:ListItem&gt;
&lt;/aspropDownList&gt;

&lt;table align="center"&gt;
&lt;tr valign="baseline"&gt;
&lt;td nowrap align="right"&gt; &lt;/td&gt;
&lt;td&gt;&lt;input type="submit" value="Insert record"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;
&lt;asp:TextBox ID="txtFullDate" runat="server" /&gt; &lt;/p&gt;
&lt;p&gt;
&lt;input type="hidden" name="TestDate" value="(&lt;%=ddlMonth.SelectedItem.value &"/"& ddlDay.SelectedItem.value &"/"& ddlYear.SelectedItem.value%&gt<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>"&gt;
&lt;input type="hidden" name="MM_insert" value="form1"&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;


Edited by - dakocada on 23 Mar 2006 10:14:34

Replies

Replied 23 Mar 2006 10:15:00
23 Mar 2006 10:15:00 dako cada replied:
damn smilies

Reply to this topic