Accessing the contents of a form textbox using the ID?

Hi,

I'm using some third party software to deliver HTML/ASP generated pages to the browser.  The browser (the IE engine) actually sits inside the third party software.   When the third party software starts up it gets invoked by the user by passing a account number into it.   The third party software then runs it's own component methods to look up the account number from a MSSQL database and return the details of that account.

The returned data gets populated into FORM fields identified by the id, for example

<form name=account>
<input id=accountname size=20>

<input id=accountpassword size=10>
</form>
etc...

So when the page first loads all of the data has already been queried from the db and then pushed into those form boxes, based on the id.  The id tag is the database table field name, fyi.


So my question is... is there a way to now access the contents of those fields, like:

var accountname
accountname = document.account.accountname.value

and then I can use that data?


Caspar
LVL 1
CasparUKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sajuksCommented:
just use
document.getElementById('accountname').value
0
sajuksCommented:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function getVal()
{
var acc = document.getElementById('accountname').value
var accp = document.getElementById('accountpassword').value
alert ( 'accountname is ' +acc )
alert ( 'accountpassword is ' + accp)
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<form name=account>
<input id=accountname size=20 value = "ACCT HEAD">
<input id=accountpassword size=10 value = "TXT">
<input type = "button" onclick = "getVal()">
</form>
</BODY>
</HTML>

Once you have the values you could do the validations/manipulations that you want
0
CasparUKAuthor Commented:
I agree that that shd work, but it doesn't in my case... :(

The third party software, which creates uses an object somewhat prevents that information to be captured...


The below code gets loaded when the page is viewed:
Dim AgentDisp

Sub Window_OnLoad
  Set AgentDisp = GetObject("","AgentDisp.AgentDispatcher")

  AgentDisp.PopulateFields

  window.Focus
End Sub



Where in the webserver can I gain access to this object?


C
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

sajuksCommented:
You're using vbscript  ? What actually are you trying to do and where? The page is generated by a third party software .Fine. Now you want to access these values ? Ok . From where ? Are you trying to modify the generated  page or what ?Sorry i cant seem to get the flow rite.Can you elaborate a bit.
0
CasparUKAuthor Commented:
Yep VBscript.... the code above works fine...but the problem was that it was being called before the form was populated, i.e. within the HTML HEAD, but the form is populated by an OnLoad call...

Code so far:
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function FunPhoneNum()
{
var PhoneNum = document.getElementById('PhoneNum').value
alert ( 'accountname is ' +PhoneNum )
}
//-->
</SCRIPT>
<form name=frmPhoneNum>
      <INPUT id=PhoneNum Size=15>      
      <input type = "button" onclick = "FunPhoneNum()">
      
</form>      
<a href="javascript:FunPhoneNum()">Confirm call</a>

</BODY>
</HTML>


The problem now is how do I submit this form automatically without using the onload call, as this is already being used and I don't think I can use it too...

The page needs to fully load...can I have like a redirect at the bottom of the page appending the form field PhoneNum in the QueryString, if so how?

C
0
sajuksCommented:
The page loads and then u need to redirect.Not sure but check this am assuming that the value of PhoneNum
has already been set. You could also call two funcs on body onload, but since you mention that it cant be used////

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<form name=frmPhoneNum>
     <INPUT id=PhoneNum Size=15 value = 1234>    
    <input type = "button" onclick = "FunPhoneNum()">
</form>    

<script language ="javascript">
location.href = "http://search.google.com?id="+document.getElementById('PhoneNum').value
</script>


</BODY>
</HTML>
0
CasparUKAuthor Commented:
I think there must be a delay from the time the page loads to the time the field is automatically populated...cause whenever I try and do anything auto submit/redirect that field is always empty! ah! :S

Can a pause be inserted before the location.href redirection?
0
CasparUKAuthor Commented:
This works a treat, since it pauses the page and allows the 3rd part application container to finish populating the field:

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function getPhoneNum()
{
var PhoneNum = document.getElementById('PhoneNum').value
location.href = "start.asp?bob=4&PhoneNum="+document.getElementById('PhoneNum').value
}
//-->
</SCRIPT>
<form name=frmPhoneNum>
      <INPUT id=PhoneNum Size=15>      
      <input type = "button" onclick = "getPhoneNum()">      
</form>      
</BODY>
</HTML>

but the user still has to do something :(

Any ideas how I can automate a 1/2 second pause?

0
sajuksCommented:
//try this , setTimeout is measured in milliseconds,
<HTML>
<HEAD>
<script>
function callit()
{
location.href = "http://search.google.com?id="+document.getElementById('PhoneNum').value
}
</script>
</HEAD>
<BODY>
<form name=frmPhoneNum>
     <INPUT id=PhoneNum Size=15 value = 1234>    
    <input type = "button" onclick = "FunPhoneNum()">
</form>    

<script language ="javascript">
setTimeout( "callit()",500)
</script>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.