I have a form action that needs to have its value set from a variable. I need to set the variable once and it will be reflected many times throughout the DOM.
So:
variable = "somthing.html"; ...
I have a form action that needs to have its value set from a variable. I need to set the variable once and it will be reflected many times throughout the DOM.
So:
variable = "somthing.html"; ...
You can then change the form action to be equal to the variable name. Something like the following.
var variableName = "myform.htm";
this.form.action = variableName;
Edit, you can also do this with other elements, just like you would with any other piece of javascript, using things such as "getElementById()" to get the items from the DOM
i am not sure if this is what you are asking, but you could change the action of the document with this:
document.formname.action = "something.html";
This will cause all FORMs to get the variable action:
<script src="jquery-1.2.6.pack.js"></script>
<script>
$(document).ready(function() {
var variable = "something.html";
$('form').attr("action", variable);
});
</script>