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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing to a file\finding field input

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
I'm brand spankin new at HTML. I had to learn it for a project im doing in C++. My problem is as follows. I have to take the string inputed into an edit field in the HTML file and utilize it in C. My problem is, I dont have any idea how to find what's entered into a field in the HTML file. Please remember, I am new at HTML, so this may sound stupid. can HTML files write to other files? such as text. Ths HTML is offline the whole time. any help I could get would be greatly appreciated. Noone I know seems to know but I'm expected to know myself. Cyprus
 
Cyprus,

The easiest way to do this is to use server side scripting on the web server to retrieve the values entered into HTML text fields.

The only other way you can do this without server side scripting is by posting the form using the GET method. This way the results are appended to the URL being sent to the next page. Then you can use JavaScript to strip down the URL and get the value. It's a little complicated but here's a brief example.
Code:
<html>
<head>
<script Language=&quot;JavaScript&quot;>
<!--

//-->
</script>
</head>
<body>
<form method=&quot;get&quot;>
First Name: <input type=&quot;text&quot; name=&quot;FN&quot;><br>
<input type=&quot;submit&quot; value=&quot;Send&quot;>
</form>
</body>
</html>
Run that page in your browser. Put something in the field and press the Send button. Now look at the URL, see how it appends the field name and value into the URL. Then, you can use JavaScript to retrieve that information. To send the values to a different page, use this as your form tag.

<form method=&quot;get&quot; action=&quot;somepage.html&quot;>

Then you'll write the JavaScript function on that page to get the result.

However, I have no idea how to post the results to a C++ program, so I'm hoping this sheds a little bit of light on reading values in HTML.

ToddWW
 
Sounds like you're being asked to host the WebBrowser Control in your C++ program.

Nothing to do with a server or scripting at all.

Go to and do a search on &quot;Reusing Browser Technology&quot; to get started.
 
the HTML file is offline. Actually, the place where I work uses it to install their product, as opposed to the generic installer. Because its quicker and more reliable. But I need to take the information from the HTML and stick it into the program im writing for them. The only way I know to do this is to have the HTML write to a file and read the file from there. But I never thought html's would do that. Can they? if so, how? Cyprus
 
In general terms, NO. Internet Explorer and Netscape have been very careful to not allow web developers to have file access to a visitors machine. I use the word visitor as being anyone who is launching IE or NS on a computer, whether to access a public web site or just some local files. IE and NS treat it all the same.

There might be some plugin or Active X control that may work, but again, in general terms, you'll never get IE or NS to write to, or save a file on the visitor's computer. Makes sense doesn't it ?? :)

ToddWW
 
Yup. I was almost positive it would end up like that, but I figured I'd try and ask anyways. And that answered my question, with the reply I was sure was to come. Oh, well. stuff happens. What about saving the HTML itself after the user inputs his data? could that be done, if the HTML was offline?

Cyprus
 
Nope.. Again, where would you save it if you don't have file access to the visitor's machine. I think you're stuck here. You might want to consider a different app other than IE or NS for installing your software.

Sorry :-(

ToddWW
 
Uh-oh. OK, thats what I suspected, thanks. Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top