Solved

Accessing FORMs data

Posted on 1998-07-16
8
158 Views
Last Modified: 2010-04-09
Ok, I know It's probably a lame question but still:

How do I access a FORM?

I need to put values read from an SQL database into a form using VBScript but the only function I know of is Request.Form and it doesn't seem to accept input, only output...eg you can't do this:
Request.Form("Name") = "Dennis"

Help...please!!
0
Comment
Question by:Dempa
  • 4
  • 4
8 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1844641
Supposing you use ASP, and are able to get the necessary data out of the database with a recordset named RS, you can display them in a form like this:

<input type="text" name="name1" value="<%=RS("field1")%>">

or if using a textarea:

<TEXTAREA rows=5 cols=45 name="name2" wrap="physical"><%=RS("field2")%></TEXTAREA>





0
 

Author Comment

by:Dempa
ID: 1844642
I know, but I need to access the form AFTER it's been loaded...

Like this:
<FORM NAME="MyForm" ACTION="sub.asp" METHOD=POST>
<INPUT TYPE=TEXT NAME="Name" SIZE=15 MAXLENGTH=15>
</FORM>

and then I need to set the value to something from a database using VBscript in Active Server Pages, something like this:

Form("Name") = rs.Fields("A_Name")

The question is, how?
0
 
LVL 28

Expert Comment

by:sybe
ID: 1844643
You can change formvalues using javascript

document.form_name.field_name.value = "new value"

The get the values to Javascript, you'll have to get back to the database. So that means that a document needs to be reloaded. This must not necessarily be the document with the form, as Javascript can also change form values in other documents (as long as you know how to find that document (within a frameset or using a new window that is opened)

Another solution is to get all the data you might need to the document the first time and store them in Javascript variables and call those whenever you need them.

Anyway, you'll need some javascript.

I can give you some code if you make clear on what event the form values have to change.

0
 

Author Comment

by:Dempa
ID: 1844644
But...I have to do this in VBScript.

The form values are to be set when the page is _almost_ finished loading....Right after the form is loaded (i.e. after the </FORM> tag) I have a function call:

</FORM>
<% FixValues %>
</BODY>
</HTML>

And this function is supposed to put the values in their right places in the form...

0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 28

Expert Comment

by:sybe
ID: 1844645
Don't despair, you can use VBScript in your serverside code, I propose to use javascript client side.

Your VBScript could look like this:


<script>
<%
' code to get make the connection and the recordset
' Server side VBscript writes Client side Javascript here
Response.write "var strField1 = " & RS("field1") & ";"
Response.write "var strField2 = " & RS("field2") & ";"
Response.write "var strField3 = " & RS("field3") & ";"
' the rest is HTML/JavaScript
%>
</script>

<form name="frmAnyName">
<input type="text" name="field1">
<input type="text" name="field2">
<input type="text" name="field3">
</form>

<script>
document.frmAnyName.field1.value = strField1;
document.frmAnyName.field2.value = strField2;
document.frmAnyName.field3.value = strField3;
</script>

What this does is only filling the values of the form when the page is (almost) loaded. Any changes that the user makes before the form fields are filled by Javascript will be overwritten.
0
 

Author Comment

by:Dempa
ID: 1844646
OK. Good enough answer...Post it as an answer and I´ll give you the points..

btw, thanx! :-)
0
 
LVL 28

Accepted Solution

by:
sybe earned 60 total points
ID: 1844647
ok, thanks
0
 

Author Comment

by:Dempa
ID: 1844648
Adjusted points to 60
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses how to create an extensible mechanism for linked drop downs.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now