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

post hidden values

Status
Not open for further replies.

onressy

Programmer
Joined
Mar 7, 2006
Messages
421
Location
CA
not sure why this isn't working, whats the flaw in my logic?


I'm hoping when the user click the link to initiate the LastSaving function that a form will be created with the appropiate values as hidden and submits to another page for db table updating. Thanks


<a href="javascript:ListSaving();">Save This List</a>

Code:
<script>
function ListSaving() {
document.write "<form name='f1' action='recruitmentListSave.asp' method='post'>";
document.write "<input type='hidden' name='ID' value=''>";
document.write "<input type='hidden' name='LastName' value=''>";
document.write "<input type='hidden' name='FirstName' value=''>";
document.write "<input type='hidden' name='Email' value=''>";
document.write "<input type='hidden' name='Fax' value=''>";
document.write "<input type='hidden' name='Province' value=''>";
document.write "<input type='hidden' name='RegistrationURL' value=''>";
document.write "<input type='hidden' name='UnsubscribeURL' value=''>";
document.write "<input type='hidden' name='AccessCode' value=''>";
document.write "<input type='hidden' name='Specialty' value=''>";
document.write "<input type='hidden' name='Profession' value=''>";
document.write "<input type='hidden' name='SurveyName' value=''>";
document.write "<input type='hidden' name='SurveyID' value=''>";
document.write "<input type='hidden' name='creator' value=''>";
document.write "<input type='hidden' name='modifier' value=''>";
document.write "</form>";


      document.forms["f1"].elements["ID"].value = 'v1';
      document.forms["f1"].elements["LastName"].value = 'v2';
      document.forms["f1"].elements["FirstName"].value = 'v3';
      document.forms["f1"].elements["LastName"].value = 'v4';
      document.forms["f1"].elements["Email"].value = 'v5';
      document.forms["f1"].elements["Fax"].value = 'v6';
      document.forms["f1"].elements["Province"].value = 'v7';
      document.forms["f1"].elements["RegistrationURL"].value = 'v8';
      document.forms["f1"].elements["UnsubscribeURL"].value = 'v9';
      document.forms["f1"].elements["AccessCode"].value = 'v10';
      document.forms["f1"].elements["Specialty"].value = 'v11';
      document.forms["f1"].elements["Profession"].value = 'v12';
      document.forms["f1"].elements["SurveyName"].value = '<% = gstrSessionSurveyName %>';
      document.forms["f1"].elements["SurveyID"].value = '<% = gstrSessionSurveyID %>';
      document.forms["f1"].elements["creator"].value = '<%Session("uzor")%>';
      document.forms["f1"].elements["modifier"].value = '<%Session("uzor")%>';

alert("List Saved!");
document.f1.submit();

}
</script>
 
If this code is called AFTER the page has been written initially, it will delete the original page (including the Javascript function) and rewrite ONLY the first line of the form to the page (I'd guess). The first document.write method call will be what overwrites everything.

Why don't you write the form to the page when it loads, since all the form elements are hidden, and have a regular submit button? What you have now is a rather roundabout way of accomplishing what you want.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top