Type mismatch problems with select box list

N

.Net Sports

I have an item that goes into sql database coming from a select
pulldown list.:

<br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
RSFORM("level")&"</option><option value=1>1</option><option value=2>2</
option></select>

Level is an integer datatype in the dbase, and is either a numeral 1,
2 ,or 3

when trying to either update or insert into the dbase:

RSEVENTS("level") = cint(request("level"))

I get a vbscript Type mismatch: 'cint' on this line; get the same
error no matter if i leave the function blank " request("level")

??
NS
 
B

Bob Barrows

..Net Sports said:
I have an item that goes into sql database coming from a select
pulldown list.:

<br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
RSFORM("level")&"</option><option value=1>1</option><option
value=2>2</ option></select>

Level is an integer datatype in the dbase, and is either a numeral 1,
2 ,or 3

when trying to either update or insert into the dbase:

RSEVENTS("level") = cint(request("level"))

I get a vbscript Type mismatch: 'cint' on this line; get the same
error no matter if i leave the function blank " request("level")

??
NS
Show us the result of

Response.Write request("level")
 
E

Evertjan.

Bob Barrows wrote on 21 dec 2009 in
microsoft.public.inetserver.asp.general:

What is "leaving the function blank?
What is "blank", an empty string?

Do you mean the argument of cint() ?

Cint() errors out if the argument is not convertable to a number,
so an empty string will give an error.

Show us the result of

Response.Write request("level")

This will possibly not help you, Bob,
as you cannot see the difference between
"1" and +1.

====================

and never never use request("level")

specify what type of request you want to read, like:

request.cookies("level")

request.form("level")

request.querystring("level")

Request.servervariables("..")

or other.
 
B

Bob Barrows

Evertjan. said:
Bob Barrows wrote on 21 dec 2009 in
microsoft.public.inetserver.asp.general:


This will possibly not help you, Bob,
as you cannot see the difference between
"1" and +1.

Are you sure? Did you look at his source?
 
N

.Net Sports

Bob Barrows wrote on 21 dec 2009 in
microsoft.public.inetserver.asp.general:




What is "leaving the function blank?
What is "blank", an empty string?

Do you mean the argument of cint() ?

Cint() errors out if the argument is not convertable to a number,
so an empty string will give an error.



This will possibly not help you, Bob,
as you cannot see the difference between
"1" and +1.

====================

and never never use request("level")

specify what type of request you want to read, like:

request.cookies("level")

request.form("level")

request.querystring("level")

Request.servervariables("..")

or other.

If i don't need to change the Level when editing the record, then i
want to leave what their existing level number is in the first line of
the select option box: <select name=level><option value= SELECTED>"&
RSFORM("level")&"</option><option value=1>1</option><option
value=2>2</
option></select>

I tried response.writing the request("level") on the next page, and it
is blank , so something is not coming across in the post right:

<form action="resources-edit-post.asp?qencl=admin" name="frmUser"
Method="Post">
''' content
</form>
 
B

Bob Barrows

..Net Sports said:
If i don't need to change the Level when editing the record, then i
want to leave what their existing level number is in the first line of
the select option box: <select name=level><option value= SELECTED>"&
RSFORM("level")&"</option><option value=1>1</option><option
value=2>2</
option></select>

I tried response.writing the request("level") on the next page, and it
is blank , so something is not coming across in the post right:


Look at the value attributes of each of your option elements ... which one
is selected when you submit the form? What is the value of that selected
option?
 
A

Adrienne Boswell

If i don't need to change the Level when editing the record, then i
want to leave what their existing level number is in the first line of
the select option box: <select name=level><option value= SELECTED>"&
RSFORM("level")&"</option><option value=1>1</option><option
value=2>2</
option></select>

I tried response.writing the request("level") on the next page, and it
is blank , so something is not coming across in the post right:

<form action="resources-edit-post.asp?qencl=admin" name="frmUser"
Method="Post">
''' content
</form>

You've got a few bad things going on here.

1. You really should quote all your HTML attributes. It makes debugging
a lot easier.
2. What is the value of the option? You have a blank value, you really
do, and had you quoted attribute values correctly you would have seen
that. Look at the source of the document when it has been rendered in a
browser and you will see what I mean. This is the correct method:

<option value="<%=rsform("level")%>" selected><%=rsform("level")%>
</option>

3. Are you looping through the records - from your naming conventions it
appears you are, so why would you have ALL options selected? You have
to put some appropriate if statements in there.

4. It's not a good idea to use request("level") - because you are not
explicitly telling the server to look for a post value. You should
always use request.form("field") for post method, or request.querystring
("field") for get method, or request.cookies("field") for cookies, or
request.servervariables("field").

I got into trouble a long time ago, before someone here showed me the
error of my ways, where I had an input that was called url, and when I
did request("url") it was giving me the url of the page, not information
the user had posted in the form. IIRC server variables are read first.

5. Using the name attribute of the form element is deprecated. You
would do better to use the id attribute, especially if you are going to
be using client side scripting for modern browsers.
 
D

Dan

.Net Sports said:
I have an item that goes into sql database coming from a select
pulldown list.:

<br>ACCESS LEVEL:<br> <select name=level><option value= SELECTED>"&
RSFORM("level")&"</option>

There's your problem, right there, at the value=. Where's the value? For
example, is RSFORM("level") is the value 1, the HTML becomes

<select name=level><option value= SELECTED>1</option>

so if the user picks 1 from the list (which is pre-selected so is highly
likely), the value is blank because you have not provided the value. The
change for this line should be something like

<br>ACCESS LEVEL:<br> <select name=level><option value=" & RSFORM("level") &
" SELECTED>" & RSFORM("level") & "</option>
 
E

Evertjan.

Bob Barrows wrote on 22 dec 2009 in
microsoft.public.inetserver.asp.general:
Are you sure? Did you look at his source?

Possibly I was,

.... but not now, as both will be accepted by cint()
 
B

Bob Barrows

Evertjan. said:
Bob Barrows wrote on 22 dec 2009 in
microsoft.public.inetserver.asp.general:


Possibly I was,

... but not now, as both will be accepted by cint()
I guess you're missing the point. If the form above is submitted with
the default selection,
request("level")
, or, more correctly (as you pointed out):
request.form("level")
, will return an empty string, in which case cint("") will raise a type
mismatch error.
 
N

.Net Sports

You've got a few bad things going on here.

1. You really should quote all your HTML attributes.  It makes debugging
a lot easier.
2. What is the value of the option? You have a blank value, you really
do, and had you quoted attribute values correctly you would have seen
that.  Look at the source of the document when it has been rendered in a
browser and you will see what I mean.  This is the correct method:

<option value="<%=rsform("level")%>" selected><%=rsform("level")%>
</option>

3. Are you looping through the records - from your naming conventions it
appears you are, so why would you have ALL options selected?  You have
to put some appropriate if statements in there.

4. It's not a good idea to use request("level") - because you are not
explicitly telling the server to look for a post value.  You should
always use request.form("field") for post method, or request.querystring
("field") for get method, or request.cookies("field") for cookies, or
request.servervariables("field").  

I got into trouble a long time ago, before someone here showed me the
error of my ways, where I had an input that was called url, and when I
did request("url") it was giving me the url of the page, not information
the user had posted in the form.  IIRC server variables are read first.

5. Using the name attribute of the form element is deprecated.  You
would do better to use the id attribute, especially if you are going to
be using client side scripting for modern browsers.


Thanks! the main culprit was not having the current value for the
record in the value tag: <option value="& RSFORM("level")&"
SELECTED>"............
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top