473,490 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

set form action

I have a FORM tag that looks like this:

<form name="form1" id="form1" method="post" action="go.php">

I can leave off the ACTION attribute and have javascript add it on load,
for example:

<script type="text/javascript">
window.onload = function() {
var frm = document.getElementById("score");
frm.action = "go.php";
frm.submit();
}
</script>
</head>

<body>
<form name="frm" id="frm" method="post">

I tried it and it seems to work but I'm uncertain if it's the "best" way
to add an attribute.
Andrew Poulos
Jul 23 '05 #1
2 6504


Andrew Poulos wrote:

I can leave off the ACTION attribute and have javascript add it on load,
for example:

<script type="text/javascript">
window.onload = function() {
var frm = document.getElementById("score");
Neither above nor below I can see an element with id "score".
frm.action = "go.php";
frm.submit();
}
</script>
</head>

<body>
<form name="frm" id="frm" method="post">

I tried it and it seems to work but I'm uncertain if it's the "best" way
to add an attribute.


It depends on the criteria as to what you regard as best, if you want to
cover old browsers like Netscape 4 then it is better to use
var frm = document.forms.frm;
frm.action = "go.php";

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Andrew Poulos wrote:
I have a FORM tag that looks like this:

<form name="form1" id="form1" method="post" action="go.php">

I can leave off the ACTION attribute and have javascript add it on load,
for example:

<script type="text/javascript">
window.onload = function() {
var frm = document.getElementById("score");
frm.action = "go.php";
frm.submit();
}
</script>
</head>

<body>
<form name="frm" id="frm" method="post">

I tried it and it seems to work but I'm uncertain if it's the "best" way
to add an attribute.
Andrew Poulos


The action attribute is required, even if it's empty (though as you
point out, most browsers will not get too upset about it).

<URL:http://www.w3.org/TR/html401/interact/forms.html#edef-FORM>

--
Fred
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3755
by: bissatch | last post by:
Hi, I have been trying to come up with an idea to reduce double submissions where a user clicks refresh and, for example, another row is INSERT into a table. Originally, I would have a form...
10
6591
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> ...
5
8393
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform'...
6
13360
by: tencip | last post by:
Hi everyone, So, i've got a form that is very simple. It hold three elements: username, password, and domain. The goal here is to have the form submit the login to an administrative section...
2
1624
by: Myk Quayce | last post by:
I have a small .aspx page that uses old style forms with client-side JavaScript validation. Everything works fine until I try to upate the database with some new information. I must be doing...
4
5308
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label...
13
69975
by: deko | last post by:
I have a basic feedback form with a submit button. After the "send" button is clicked, I want the user to be redirected to a different page that says "Your message has been sent." How do I do...
6
19132
by: Arthur | last post by:
Hello. How might it be possible to change where a form action is directed based on a selected option. For example I have this: <FORM METHOD = "post" ACTION = ""> And a drop down such as
12
6918
by: Daniel Klein | last post by:
I'm pretty new at php and web stuff so please be gentle with me. I'm trying to get a form to submit when the user presses the Enter key. I do not want to use javascript. I've googled this to...
1
3300
by: chromis | last post by:
Hi, I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following: - Bean (Contact.cfc) - Data Access object (ContactDAO.cfc) - Gateway...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.