Re: Another Drop List question
From: Roland Hall (nobody_at_nowhere)
Date: 01/19/05
- Next message: Bob Barrows [MVP]: "Re: Another Drop List question"
- Previous message: C White: "Re: Another Drop List question"
- In reply to: C White: "Another Drop List question"
- Next in thread: C White: "Re: Another Drop List question"
- Reply: C White: "Re: Another Drop List question"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 Jan 2005 17:56:06 -0600
"C White" wrote in message news:6cOdnZ5EAf5ecXPcRVn-vA@rogers.com...
: I've got another drop list problem
:
: I am using the following code where users select a name, but it should
: pass a name and email into the table
:
: <select name="user">
: <option value="<% Response.Write (rsUser("Name")) %>">
: <% Response.Write (rsUser("Name")) %>
: <input type="hidden" name="Email" value="<% Response.Write
: (rsUser("Email")) %>">
: </option>
: </select>
: everything seems to be ok when i test the form as the source it produces
: is this:
:
: <select name="user">
: <option value="1st guy">
: 1st guy
: <input type="hidden" name="Email" value="1st.guy@domain.com">
: </option>
:
: <option value="2nd guy">
: 2nd guy
: <input type="hidden" name="Email" value="2nd.guy@domain.com">
: </option>
: </select>
:
: so everything seems fine, it is pulling the information from the 1st
: table just fine, but when i submit to add the information to the 2nd
: table it does not add the email value, i get the following error
:
: Microsoft JET Database Engine (0x80004005)
: Field 'Table.Email' cannot be a zero-length string.
:
: if i change the email field in the table to allow zero length i don't
: get the error, but the email does not go into the table, just the name
: is added (it's an access 2000 database)
:
: any ideas what i am doing wrong here?
Two things:
1. If your database field is set to not allow zero-length strings, then it
needs data. This is not the code where you insert the data, it is the code
where you are showing values you have received from the data. Have you
verified the data is not present in the database? Are you getting an error
when you insert data or do you have an On Error Resume Next line in your
insert code?
2. I have found it is often easier and possibly less of a performance hit if
you put your HTML in strings and then pass them through a routine to write
it to the page.
Ex.
<%@ Language=VBScript %>
<%
.
.
.
sub prt(str)
Response.Write(str & vbCrLf)
end sub
dim s
s = "<select name=""user"">" & vbCrLf & _
"<option value=""" & rsUser("Name") & """>" & rsUser("Name") & vbCrLf & _
"<input type=""hidden"" name=""Email"" value=""" & rsUser("Email") & """>"
& vbCrLf & _
"</option>" & vbCrLf & _
"</select>"
prt s
%>
I like this better because my server is not switching back and forth to read
ASP code and HTML and for me, it makes it easier to line up my quotes. I
know that my string needs quotes and if I assign a value to an HTML element
that I need 3, otherwise, adding quotes for HTML means I need 2. So, single
around the edges, 2 for all HTML values and 3 if I need to pass a value from
ASP.
This:
& vbCrLf
...adds a carriage return, line feed to the HTML output so the code is more
legible. It has nothing to do with how the code runs.
& _ could probably be shortened to just _ which is a concatentation
character so VBScript code can resume on the next line.
I'm building a string that gets passed once and my parser reads the whole
page, rather than switching back and forth to read ASP, HTML, ASP, etc. I
am told this is how the parser works. I could redefine "s" as above, or I
could even have an array of statements, but it gives me better control over
the output of my data.
instead of ...
<%@ Language=VBScript %>
<%
.
.
.
%>
<select name="user">
<option value="<% Response.Write (rsUser("Name")) %>">
<% Response.Write (rsUser("Name")) %>
<input type="hidden" name="Email" value="<% Response.Write
(rsUser("Email")) %>">
</option>
</select>
<%
...
%>
...at the very least you could replace the Response.Writes with =
<select name="user">
<option value="<% = rsUser("Name") %>">
<% = rsUser("Name") %>
<input type="hidden" name="Email" value="<% = rsUser("Email") %>">
</option>
</select>
HTH...
-- Roland Hall /* This information is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. */ Technet Script Center - http://www.microsoft.com/technet/scriptcenter/ WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp
- Next message: Bob Barrows [MVP]: "Re: Another Drop List question"
- Previous message: C White: "Re: Another Drop List question"
- In reply to: C White: "Another Drop List question"
- Next in thread: C White: "Re: Another Drop List question"
- Reply: C White: "Re: Another Drop List question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|