Avatar of ITgirl
ITgirlFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

Save Parameters to Text File, and then pass parameters to further text fields in form for further information to be added

I am relatively new to scripting and would like to have the user enter a parameter into a text field, for that data to be saved to a text file, and then be able to pass those parameters to another form.  I suppose that this is similar to a cookie, but don't want to use that method.

Also I am unsure how it will be best to script this, I have basic knowledge in ASP and Javascript and would like to use either of these technologies.

I would therefore appreciate some pointers/possible code on how to complete this.

Many Thanks
Web Languages and Standards

Avatar of undefined
Last Comment
COBOLdinosaur
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

>>>I suppose that this is similar to a cookie, but don't want to use that method.

The cookie method was developed because you can't do what you want to do.  Ordinary web pages are not permitted to access the the client's hard disk except for caching and cookies, and those may or may not be available depending on user preferences.  Even with risky elements like activex you have to have the users permission.  You cannot just write things out the hard drive.

If you need intemediate processing do it on the server. Send the first page to a script that saves the information server side and generates the next part of the form with the parameters included.

Cd&
Avatar of ITgirl
ITgirl
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Ok so may be I didn't make myself clear - this is for client side (on an intranet) where the user has full knowledge of the file being saved.
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Save a file clientside with partial contents of a page:

- Create a hidden iframe anywhre on the page:
<iframe name="fHidden" style="position:absolute;visibility:hidden;" src="about:blank"></iframe>

- add following script to the head of the page
<script type="text/javascript">
function saveContent(sText)
{
   document.frames['fhidden'].document.body.innerHTML = sText;
   document.frames['fhidden'].document.execCommand("SaveAs");
  return true;
}
</script>



Then call it this way from the form tag:

<form name="yourform" action="yourscript.asp"
onsubmit="saveContent(document.forms['yourform'].yourtextfield.value)";

The user will get a dialog and must agree to the data being saved on their hard drive. After the file has been saved the form action will be executed

Cd&
 


Avatar of ITgirl
ITgirl
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

As I previously mentioned I am quite new to scripting - is there any way this can be done in javascript - as I am a bit happier using Javascript than asp.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Web Languages and Standards
Web Languages and Standards

Web development can range from developing the simplest static single page of plain text to the most complex web-based internet applications, electronic businesses, and social network services using a wide variety of languages and standards, including the familiar HTML, JavaScript and jQuery, ASP and ASP.NET, PHP, ColdFusion, CSS, PHP, Flex and Flash, but also the implementation of a broad list of standards including XML, WSDL, SSDL, VoiceXML and many more.

40K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo