?
Solved

Accessing FORMs data

Posted on 1998-07-16
8
Medium Priority
?
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

 

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
 
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 240 total points
ID: 1844647
ok, thanks
0
 

Author Comment

by:Dempa
ID: 1844648
Adjusted points to 60
0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

762 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