Groups | Blog | Home
all groups > inetserver asp general > november 2003 >

inetserver asp general : changing a Form Variable


Alex
11/24/2003 8:22:10 PM
This may sound like a simple question but I really dont' know how to do
this.

I know you can call a Form Variable in a VBscript using
Request.Form("FieldName") and make equal a local variable like:

str = Request.Form("FieldName")

Now if do this:

str = "This is the new value"

How do you make FieldName equal str. So In a sense I want this to happen

FieldName = str

I need this so that when FieldName gets posted to the DB the new value get
sent.

Any ideas?

Bullschmidt
11/24/2003 10:22:52 PM
In the updating to the database:
objRS("MyField") = str

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Developersdex http://www.developersdex.com ***
Ray at <%=sLocation%
11/25/2003 12:36:28 AM
I'm not really sure why you'd want to do this, unless you're trying to
dynamically create form field names, in which case, you'd do:

<% sVar = "SomeFieldName %>
<input name="<%=sVar%>" type="text">

You cannot reassign the names of the form elements when the form is posted.
The Request.Form collection is read-only.

Ray at home

[quoted text, click to view]

Tom B
11/25/2003 8:08:36 AM
If you open your database with the right kind of cursor, you can do the
update.

Do While not objRS.EOF
objRS("MyField")="new value"
objRS.MoveNext
Loop
objRS.Update

I prefer to use an UPDATE Sql statement, to make the changes
if objConn is my connection....

Dim sSQL
Dim newValue
newValue="new value"
sSQL="UPDATE tablename SET MyField='" & newValue & "' WHERE columnUniqueID=
X"
objConn.Execute sSQL


In this way you aren't pulling down a recordset just so you can do an
update.

If you need to display the "updated" data, just do the UPDATE first.



[quoted text, click to view]

AddThis Social Bookmark Button