Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:31:24+00:00 2026-06-11T21:31:24+00:00

I have some old code with document.write in it. <script type=text/javascript language=JavaScript1.2> document.write(‘<form name=InvGenPayDonation

  • 0

I have some old code with document.write in it.

<script type="text/javascript" language="JavaScript1.2">
document.write('<form name="InvGenPayDonation" action="'+PostURL+'" onsubmit="return validateForm();" method="POST">');
</script>

How can I replace action with a javascript variable that has been determined when the page was loaded? Here is that code, which is not part of a function. (I’ve substituted names, so the substr indexes are not correct, but I’m sure you get the point.)

// Check where we came from so that we can go to the right spot when the
// form gets posted from outside of our HTML tree.
var PostURL = '/event.php';

if (window.location.href.substr(0, 21) == 'http://10.10.10.10:80')
  PostURL = 'http://10.10.10.10:8580/event.php';
else if (window.location.href.substr(0, 14) == 'http://webapps')
  PostURL = 'http://10.100.0.11:8580/event.php';
else if (window.location.href.substr(0, 7) == 'webapps')
  PostURL = 'http://10.10.10.10:8580/event.php';
else if (window.location.href.substr(0, 10) == 'http://www')
  PostURL = 'https://secure.french.toast.new_zeland.france/event.php';

I’d like PostURL to go into the form’s action. If I can do that without document.write, that would be great. I just need some help. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:31:25+00:00Added an answer on June 11, 2026 at 9:31 pm

    Some other DOM0 code should do the trick:

    // Your code from the question here
    document.forms[0].action = PostURL;
    

    Note that this assumes that your form is the first form on the page – if it is not, replace [0] with the zero-based index of the form.

    However, you can (and probably should) use a more modern solution that is not dependent on the layout of the page. The simplest is document.getElementById – simply add an ID attribute to your form (make sure the ID’s value is unique across the entire page) and then do the following:

    document.getElementById("yourFormID").action = PostURL;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some html that looks like this: <form id=MyUserControl runat=server method=post> <script language=javascript
I have some old code that uses qsort to sort an MFC CArray of
I have some old code (an old but still maintained VB6 application) that from
We have some code kicking around that uses this old internal Sun package for
I have some jQuery code something like this: $(document).ready(function() { $(img.off).click(function() { alert('on'); $(this).attr('class',
I have inherited some old code and need to convert to the latest schema
I have some old code that I'm updating to work in firefox, and I've
I am writing some oop javascript code. I have a couple of instances of
I have an old web app developed in ASP.Net with the old type code
I have some old branches in my git repository that are no longer under

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.