Forums

ASP

This topic is locked

request variable text fields and inserting into DB

Posted 26 Apr 2006 12:32:05
1
has voted
26 Apr 2006 12:32:05 Stijn Willekens posted:
Greetings All,
My english is not very good. I try to explain it so good as possible!

First I shall situate the problem:
* users can create a table with a variable # of textfields (For example 4)
* I create in the background a new table in my SQL DB like
tblUser26 with the fields ID, txt1, txt2, txt3, txt4
* the user can insert some text into a form that will dynamic created (this works fine)
the code is #textarea name="txt_txt<%= intTeller%>"# #/textarea# creates this:
#textarea name="txt_txt1"# #/textarea#

The code is working with a loop so it creates the 4 textareas.
Now the problem is to request a variable number of textfields like this:

PROBLEM 1:
temp_txt1 = Trim(Request.Form("txt_txt1")
In my code I’ve have tried a lot but I have still errors:
temp_txt" & intTeller &" = Trim(Request.Form("txt_txt" & intTeller))
ERROR: Type mismatch: 'temp_txt'

PROBLEM 2:
Now I want to dynamic update my table but only the value of my teller will be inserted!
Just testing with a basic teller for next…
for teller = 1 to 5
rsItem.Fields.Item("temp_txt" & teller).Value = temp_txt&teller
next
The value in <% Response.Write(temp_txt1)%> = “hello” but he is inserting “1”


Does anywone known a solution for this problems? It would be wonderfull !

Thanks in advance for any help provided!
Stijn.
<font color=red></font id=red>

Replies

Replied 28 Apr 2006 03:59:21
28 Apr 2006 03:59:21 micah santos replied:
problem #1 might be caused of mixing two different values such as an integer and string.

if intTeller is an integer and you're trying to stuff it with an string value, maybe you could try this:

temp_txt" & cStr(intTeller) & "= Trim(Request.Form("txt_txt" & cStr(intTeller)))

with regards to your problem #2, here's a sample for that:

n.1asphost.com/micahsantos/comments.asp?id=5 or
Replied 28 Apr 2006 14:53:17
28 Apr 2006 14:53:17 Patrick Woldberg replied:
<b>Solution Problem 1:</b>

<pre id=code><font face=courier size=2 id=code>Execute("temp_txt" & intTeller & " = Trim(Request.Form(""txt_txt"" & intTeller))"</font id=code></pre id=code>

<b>Solution Problem 2:</b>

<pre id=code><font face=courier size=2 id=code>for teller = 1 to 5
rsItem.Fields.Item("temp_txt" & teller).Value = Eval("temp_txt" & teller)
next</font id=code></pre id=code>

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------
Replied 29 Apr 2006 15:59:11
29 Apr 2006 15:59:11 Stijn Willekens replied:
SUPER!!!

It works fine!

Thank you Thank you !!!!

Reply to this topic