Re: Another Drop List question

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Roland Hall (nobody_at_nowhere)
Date: 01/19/05


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


Relevant Pages

  • Re: Dynamically append rows to table
    ... further that you are not storing the new row's data in a database (or ... HTML tables do not have the EnableViewState property. ... textbox]") into a string variable and then split the string back into ... Dim myData as string ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: getAttribute question
    ... oddity with IE that getAttributereturns an empty string if the ... HTML specification, ... appropriate places in the HTML 4 and DOM HTML specifications. ...
    (comp.lang.javascript)
  • Re: Problem dealing with double quotes in InnerHTML
    ... there is no "bug" in IE6 with regards to what you are seeing. ... It removes quotes that aren't required. ... Won't make a hill of beans to HTML but it will ... One could say that the string is build anew ...
    (comp.lang.javascript)
  • .Replace method failing, How do you handle multiple Quotes in a String ??
    ... I have a program that parses 1.2 GB of html data which is working ... I know that the string I want to remove ... Function ReplaceTest2(patrn, replStr, str1) ... This works because there are not multiple quotes ...
    (microsoft.public.scripting.vbscript)
  • Re: [PHP] generating an html intro text ...
    ... You would have to search out and pull in all closing tags. ... grab 256 characters -- The string. ... html markup should not go towards the string length count, ...
    (php.general)