1

I have created few scripts to complete a web registration. Now each time I complete a registration on the last step it generates a 'Registration ID'. I need to capture and save this id to a file. Can we do this with JavaScript?

1
  • 2
    Where is the file you wish to save to? Is it on the server or on the local machine? Commented Dec 28, 2009 at 13:02

3 Answers 3

2

To get the registration id you can save it t a hidden element [textbox with type hidden] and get the value using javascript like this.

document.getElementById ( "txtHidRegID" ).value;

where the id of the textbox is txtHidRegID.

For the second part [file save] you cannot access files on the client side using javascript. You can save it to a file on the server side using any server side language.

Accessing file in a client machine using javascript which runs inside a sandbox will be a security hole.

Sign up to request clarification or add additional context in comments.

Comments

2

If you wish to save the ID to the server side, you can do that by throwing an Ajax request with the value to a server-side script which will save the value.

If you wish to save to a local file (client-side), then you need more than JavaScript.

To get the registration ID, use the DOM with getElementById.

Comments

1

Not directly with JavaScript. You will have to send your generated id to the server somehow. You could use XHR (AJAX) if you don't wish to refresh the page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.