changing a Form Variable

A

Alex

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?
 
R

Ray at

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
 
T

Tom B

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.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top