[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Accessing FORMs data

Posted on 1998-07-16
8
Medium Priority
?
210 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: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 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