Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling a text field in a table...

Status
Not open for further replies.

mike777

Programmer
Jun 3, 2000
387
US
Hello folks.
This is my first posting to the HTML forum. Also, my first foray into HTML for work (I've dinked around with it at home a little.). All this to say that I ask your patience if I sound like I actually am ... lost and confused. Thanks.
I have this website I am trying to automate via MS FoxPro. It is going well so far.
A problem I've encountered that I can't get around is with a table that has a cell (is that what you call a "TD" tag?) in it. Here's the code for it:
Code:
<TD class=dcell vAlign=top align=middle><INPUT class=tInput 
                  type=file size=25 value=&quot;mike&quot; name=eddFile></TD></TR>
By the way, I put that little bit in there about
Code:
value=&quot;mike&quot;
. But that is what I'm trying to do. I'm trying to automate the population of that cell.
The thing I've learned is that as long as the type=file, my code above (value=&quot;mike&quot;) doesn't have any effect on the page, and there is a &quot;browse&quot; button beside the text field. If, however, I change it so that type=text, then it works (and the &quot;browse&quot; button disappears), that is, &quot;mike&quot; shows up in the table cell on the page (I don't know if &quot;text&quot; is good code, I just played around with it. I also typed in type=monkey and &quot;mike&quot; popped up in the table cell as well. I assume that when it doesn't understand a property setting, it goes to a default, which is....text?? I don't know.)
Since I can't change the type of the cell on the website (the page I'm playing around with is a downloaded copy of the website, downloaded to my desktop), I need to know how to populate this field on the website with a value (path to a file and filename).
Any help you can provide is greatly appreciated.
Thanking you in advance.
-Mike

 
You cannot automate the population of the cell using html - html is just a mark up language, it is not something you can code.

You will need to use a client browser language to populate the fields dynamically.

This is where it gets tricky.

Sun have created a language called javascript, it is used in netscape and mozilla(and other) browsers, not to be outdone microsoft created thier own scripting language and called in jscript so as not to confuse anyone (??). They also have another client scripting language for IE, vbscript.

An amalgamation of the 2 is known as ecmascript.

With me so far ?

Anyway the answer to your question would be that you need to access the value of your input box using a client scripting language.

Assuming you only have one form on the html page, place this code between the head tags on the page.

<script type=&quot;text/javascript&quot;>
<!--
function changeInput(){
document.forms[0].elements[&quot;eddFile&quot;].value = &quot;New Value&quot;
}
//-->
</script>

You will also need to tell this script when to run.

change the body tag to read.

<body onLoad=&quot;changeInput()&quot;>

You may well need some tutorials on the subject, try here

 
Actually, you can't use a client-side script like javascript or jscript to access a database to populate text field values. (Yes, you could use an Activex module to access a database that resides on the users PC, but then that would work only with IE browsers.)

You should first hone your HTML skills a little more and then look at a scripting language like PHP or PERL. Assuming that all of this is &quot;online&quot;, you'll also have to make sure that your web host supports the scripting language you choose (or use one that they support) because it will have to reside on their systems.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top