By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,061 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

Saving of html form to server rather than locally

P: 1
I recently inherited some code that I need to adapt and I am just not a java or asp coder so need some assistance.

I have a web form created by converting an excel spreadsheet to html with several onClick events, specifically "Clear" (clears data), "Submit" (emails data) and "Save Draft" (saves draft lcoally). Customers input their data, the from works its magic and is then sent off per the clicks. User is not signed on so no session data is currently handled.

I need to make the following changes:

-Capture user session data with which to id each file when saved/submitted.

-I need to change "Save Draft" to save the draft to the server rather than the local computer.

-I need to save the finished html to the server as well as sent via email on "Submit".

Currently the forms handling this are html itself:

Expand|Select|Wrap|Line Numbers
  1.  <input id='clearBtn' class=button type=button value=' CLEAR  ' onClick='return clearForm();' onfocus='return hilite(;'>
  2. <input id='submitBtn' class=button type=button value='SUBMIT' onClick='return submitForm();' onfocus='return hilite(;'>
  3. <input id='saveBtn' class=button type=button value='  SAVE DRAFT ' onClick='return saveForm();' onfocus='return hilite(;'>
  4. <input name='emailTo' type=hidden value=''>
  5. <input name='emailFrom' type=hidden value=''>
  6. <input name='emailSubject' type=hidden value='Scaled Recipe'>
  7. <input name='emailAttachment' type=hidden value='ScaledRecipe'>
  8. <input name='submitMessage' type=hidden value=''>
  9. <input name='nextPage' type=hidden value=''>
  10. <input id='formTitle' name='formTitle' type=hidden value='ScaledRecipe'>
  11. <input id='formHtml' name='formHtml' type=hidden><!-- end -->
to a javascript (only including the "SaveDraft" portion:
Expand|Select|Wrap|Line Numbers
  1. function saveForm(){var a="To save this file on your local machine, click OK and wait for the page to refresh.";a+="\nThen, using the File..Save As menu option, save the file using any name you choose.";alert(a);a=getElementsByTagNames("input,select");for(i=0;i<a.length;i++){var b=a[i].id,c=b.substr(1);document.getElementById(c)!=null&&(c=getCellValue(c),document.getElementById(b).setAttribute("data-default",c))}a="<html>"+document.getElementsByTagName("html")[0].innerHTML+"</html>";with(document.forms[0])formHtml.value=
  2. escape(a),action=version+"/workSave.asp",method="post",submit();return!0}function printForm(a){a!=""&&alert(a.replace(/\<br\>/gi,String.fromCharCode(10)));window.print()}function formatNumber(a,b){if(isNaN(parseFloat(a)))return 0;var c=b.match(/\.(0*)/mg);return number_format(a,c==null?0:c[0].toString().length-1)}
and the save.asp
Expand|Select|Wrap|Line Numbers
  1. <%
  2. on error resume next
  3. worksheet = unescape(request("formHtml"))
  4. response.write(worksheet)
  5. response.end
  6. %>
As is works beautifully no hitches... all validation works before sending as an email.

I have gotten as far as seeing that the file will need to be saved into a server directory and at least 2 mySQL tables updated.

I just can't wrangle the code.

Code examples? Directions? HELP?!

Thanks folks!
Oct 11 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.