Ask a Question related to ASP Database, Design and Development.
-
Renie83 #1
Getting the ID of an element to check existence and pass variables.
Thanks for the tips Ray!
Okay I think I can explain better now.
What my asp page displays are some records from a database table and a
text box after each record where a user can enter a date. I would like
to be able to check if a date is entered and if so, send that line of
information to a new database table where the information will be
stored. I've read about how VBScript applys an element id to each
element in a form. And I would like to know if I can use that id to
call on these elements. Any help would be greatly appreciated and I
hope I've explained it well.
Renie83
I'm trying something like this:
if request.form("submitTop") <> "" or request.form("submitBottom")<>
"" then
// Two submit buttons can be clicked and as long as the user has not
tried to submit a blank form do this
Dim x
for x= 0 to document.myform.elements.length-1 // get the number of
elements in the form
if left(document.myform.elements(x).name,3) ="txt" then //
check to see if it's a text box
strDel= document.myform.elements(x).name +
document.myform.elements(x).id //set variable to the element with it's
id
if strDel <> " " then //if the element with this id isn't blank
insert these fields into the database
sqlD="INSERT INTO EstDelDate (EnteredBy, PO_PT, Line, FormDate,Part#,
EntryDate, EstDeliveryDate) VALUES ('" & strEmpName & "',
'" & strPurchase & "', '" & strLine & "', '" & strPDate & "', '"
& strPartNo & "', '" & Date() & "', '" & strDel & "')"
// strEmpName is user login
strPurchase-strPartNo are variables set to the fields taken from
the first database
Date() date function
strDel is my input variable
end if
end if
next
Cm2.Execute(sqlD)
end if
This is what my form kinda looks like:
do until rs3.eof
strPurchase = rs3("PURCHASE ORDER NUMBER")
strLine = rs3("LINE NUMBER")
strPDate= rs3("PURCHASE DATE")
// declare variables
%>
<tr%>
<td ><%=rs3("PURCHASE ORDER NUMBER")%></td>
<td "><%=rs3("LINE NUMBER")%></td>
<td ><%=rs3("PURCHASE DATE")%></td>
<td><input type="text" size=10 name="estDel"></td>
</tr>
<%
rs3.movenext
loop
Renie83 Guest
-
Pass the value of a check box to action page
Hi All, I know this is probably very simple but I can't figure it out. I have a checkbox on my forms page. When a user checks any one of the boxes... -
Help with my form. Checking existence of variables
I have a form which submits to another page. The submission page checks for the existence of some variables. If they don't exist it assigns a... -
how to check array element's values if this element isempty
Hi, How do you check the array elements empty or not. for example, I have array - array , and from array to array has some value, and there... -
passing variables from 'select' element in a form
Hi, I have 2 'select' element in a form. One is populated with a list of names and the other is empty Users can select 1 or more names from the... -
Can one pass variables through a selector?
In article <clund-50F2A4.12443709092003@amstwist00.chello.com>, C Lund wrote: Yes - either use an NSInvocation to perform the call, or call... -
Ray at #2
Re: Getting the ID of an element to check existence and pass variables.
Hi Renie83,
You're mixing up server-side code and client-side code. Request.Form is
server side, but document.myform.elements.length is client-side. An ASP
page will no idea what a document is, or what myform is. I suggest
something like this:
<FORM method="post" action="somepage.asp">
<INPUT name="cmdSubmit" type="submit" />
<TABLE>
<TR>
<TD>
<INPUT name="txtSomething1" type="text" />
<INPUT name="txtDate1" type="text" />
<INPUT name="hidID" type="hidden" value="1" />
</TD>
</TR>
<TR>
<TD>
<INPUT name="txtSomething2" type="text" />
<INPUT name="txtDate2" type="text" />
<INPUT name="hidID" type="hidden" value="2" />
</TD>
</TR>
<TR>
<TD>
<INPUT name="txtSomething3" type="text" />
<INPUT name="txtDate3" type="text" />
<INPUT name="hidID" type="hidden" value="3" />
</TD>
</TR>
</TABLE>
<INPUT name="cmdSubmit" type="submit" />
</FORM>
Then, on your page that processes this, if I understand right, you want to
process values only if the date textbox was filled in, do something like:
Dim aIDs, iCounter, sSQL, sSomething
aIDs = Split(Request.Form("hidID"), ", ")
For iCounter = 0 To UBound(aIDs)
sSomething = Request.Form("txtSomething" & aIDs(iCounter))
If Request.Form("txtDate" & aIDs(iCounter)) <> "" Then ''date was
entered
sSQL = "INSERT INTO [TheTable] ([Something]) VALUES ('" & sSomething
& "');"
Cm2.Execute sSQL
End If
Next
Ray at home
"Renie83" <renie83@lycos.com> wrote in message
news:8e153bdf.0307141412.12deffb0@posting.google.c om...> Thanks for the tips Ray!
> Okay I think I can explain better now.
> What my asp page displays are some records from a database table and a
> text box after each record where a user can enter a date. I would like
> to be able to check if a date is entered and if so, send that line of
> information to a new database table where the information will be
> stored. I've read about how VBScript applys an element id to each
> element in a form. And I would like to know if I can use that id to
> call on these elements. Any help would be greatly appreciated and I
> hope I've explained it well.
> Renie83
>
> I'm trying something like this:
>
> if request.form("submitTop") <> "" or request.form("submitBottom")<>
> "" then
> // Two submit buttons can be clicked and as long as the user has not
> tried to submit a blank form do this
> Dim x
> for x= 0 to document.myform.elements.length-1 // get the number of
> elements in the form
> if left(document.myform.elements(x).name,3) ="txt" then //
> check to see if it's a text box
> strDel= document.myform.elements(x).name +
> document.myform.elements(x).id //set variable to the element with it's
> id
> if strDel <> " " then //if the element with this id isn't blank
> insert these fields into the database
> sqlD="INSERT INTO EstDelDate (EnteredBy, PO_PT, Line, FormDate,Part#,
> EntryDate, EstDeliveryDate) VALUES ('" & strEmpName & "',
> '" & strPurchase & "', '" & strLine & "', '" & strPDate & "', '"
> & strPartNo & "', '" & Date() & "', '" & strDel & "')"
> // strEmpName is user login
> strPurchase-strPartNo are variables set to the fields taken from
> the first database
> Date() date function
> strDel is my input variable
> end if
> end if
> next
> Cm2.Execute(sqlD)
> end if
> This is what my form kinda looks like:
>
> do until rs3.eof
> strPurchase = rs3("PURCHASE ORDER NUMBER")
> strLine = rs3("LINE NUMBER")
> strPDate= rs3("PURCHASE DATE")
>
> // declare variables
> %>
> <tr%>
> <td ><%=rs3("PURCHASE ORDER NUMBER")%></td>
> <td "><%=rs3("LINE NUMBER")%></td>
> <td ><%=rs3("PURCHASE DATE")%></td>
> <td><input type="text" size=10 name="estDel"></td>
> </tr>
> <%
> rs3.movenext
> loop
Ray at Guest
-
Ray at #3
Re: Getting the ID of an element to check existence and pass variables.
Pull the record's primary key in to your recordset too and then you'll have
the identifier, i.e.
Ray at home
"Renie83" <renie83@lycos.com> wrote in message
news:8e153bdf.0307150442.3d82c665@posting.google.c om...message news:<u#iziwmSDHA.1576@TK2MSFTNGP12.phx.gbl>...> That is kinda what I want but I can't go through and assign each row
> it's own hidden id tag because the input boxes and rows are just being
> pulled into the asp page by using the move next of the recordset. Is
> there some way in VBScript I can refer to their ordinal number?
>
>
>
> "Ray at <%=sLocation%>" <ray@ajf8jalskdfna.sefrhja7yasdf.com> wrote into> > Hi Renie83,
> >
> > You're mixing up server-side code and client-side code. Request.Form is
> > server side, but document.myform.elements.length is client-side. An ASP
> > page will no idea what a document is, or what myform is. I suggest
> > something like this:
> >
> > <FORM method="post" action="somepage.asp">
> > <INPUT name="cmdSubmit" type="submit" />
> > <TABLE>
> > <TR>
> > <TD>
> > <INPUT name="txtSomething1" type="text" />
> > <INPUT name="txtDate1" type="text" />
> > <INPUT name="hidID" type="hidden" value="1" />
> > </TD>
> > </TR>
> >
> > <TR>
> > <TD>
> > <INPUT name="txtSomething2" type="text" />
> > <INPUT name="txtDate2" type="text" />
> > <INPUT name="hidID" type="hidden" value="2" />
> > </TD>
> > </TR>
> >
> > <TR>
> > <TD>
> > <INPUT name="txtSomething3" type="text" />
> > <INPUT name="txtDate3" type="text" />
> > <INPUT name="hidID" type="hidden" value="3" />
> > </TD>
> > </TR>
> > </TABLE>
> > <INPUT name="cmdSubmit" type="submit" />
> > </FORM>
> >
> >
> >
> >
> > Then, on your page that processes this, if I understand right, you wantlike:> > process values only if the date textbox was filled in, do somethingsSomething> >
> > Dim aIDs, iCounter, sSQL, sSomething
> > aIDs = Split(Request.Form("hidID"), ", ")
> > For iCounter = 0 To UBound(aIDs)
> > sSomething = Request.Form("txtSomething" & aIDs(iCounter))
> > If Request.Form("txtDate" & aIDs(iCounter)) <> "" Then ''date was
> > entered
> > sSQL = "INSERT INTO [TheTable] ([Something]) VALUES ('" &> > & "');"
> > Cm2.Execute sSQL
> > End If
> > Next
> >
> >
> > Ray at home
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > "Renie83" <renie83@lycos.com> wrote in message
> > news:8e153bdf.0307141412.12deffb0@posting.google.c om...> > > Thanks for the tips Ray!
> > > Okay I think I can explain better now.
> > > What my asp page displays are some records from a database table and a
> > > text box after each record where a user can enter a date. I would like
> > > to be able to check if a date is entered and if so, send that line of
> > > information to a new database table where the information will be
> > > stored. I've read about how VBScript applys an element id to each
> > > element in a form. And I would like to know if I can use that id to
> > > call on these elements. Any help would be greatly appreciated and I
> > > hope I've explained it well.
> > > Renie83
> > >
> > > I'm trying something like this:
> > >
> > > if request.form("submitTop") <> "" or request.form("submitBottom")<>
> > > "" then
> > > // Two submit buttons can be clicked and as long as the user has not
> > > tried to submit a blank form do this
> > > Dim x
> > > for x= 0 to document.myform.elements.length-1 // get the number of
> > > elements in the form
> > > if left(document.myform.elements(x).name,3) ="txt" then //
> > > check to see if it's a text box
> > > strDel= document.myform.elements(x).name +
> > > document.myform.elements(x).id //set variable to the element with it's
> > > id
> > > if strDel <> " " then //if the element with this id isn't blank
> > > insert these fields into the database
> > > sqlD="INSERT INTO EstDelDate (EnteredBy, PO_PT, Line, FormDate,Part#,
> > > EntryDate, EstDeliveryDate) VALUES ('" & strEmpName & "',
> > > '" & strPurchase & "', '" & strLine & "', '" & strPDate & "', '"
> > > & strPartNo & "', '" & Date() & "', '" & strDel & "')"
> > > // strEmpName is user login
> > > strPurchase-strPartNo are variables set to the fields taken from
> > > the first database
> > > Date() date function
> > > strDel is my input variable
> > > end if
> > > end if
> > > next
> > > Cm2.Execute(sqlD)
> > > end if
> > > This is what my form kinda looks like:
> > >
> > > do until rs3.eof
> > > strPurchase = rs3("PURCHASE ORDER NUMBER")
> > > strLine = rs3("LINE NUMBER")
> > > strPDate= rs3("PURCHASE DATE")
> > >
> > > // declare variables
> > > %>
> > > <tr%>
> > > <td ><%=rs3("PURCHASE ORDER NUMBER")%></td>
> > > <td "><%=rs3("LINE NUMBER")%></td>
> > > <td ><%=rs3("PURCHASE DATE")%></td>
> > > <td><input type="text" size=10 name="estDel"></td>
> > > </tr>
> > > <%
> > > rs3.movenext
> > > loop
Ray at Guest



Reply With Quote

