Y
yawnmoth
<form action="">
<input type="submit" name="a" value="Submit">
<input type="submit" name="b" value="Save">
</form>
<script>
function zzz() {
var vars = '', e = this.elements;
for (i=0;i<e.length;i++)
vars+= e.name + '=' + e.value + '&';
alert(vars);
}
for(i=0;f=document.forms;i++)
f.onsubmit=zzz;
</script>
If you hit either submit button you'll get an alert box with
"a=Submit&b=Save&" in it. The resultant URL, however, will only have
one of them set. ie. "b=Save" or "a=Submit" but not both.
My question is... is it possible, in javascript, to view not what
form elements exist but what form variables will be submitted?
My goal is to adapt this into a bookmarklet that I can use on
arbitrary websites.
<input type="submit" name="a" value="Submit">
<input type="submit" name="b" value="Save">
</form>
<script>
function zzz() {
var vars = '', e = this.elements;
for (i=0;i<e.length;i++)
vars+= e.name + '=' + e.value + '&';
alert(vars);
}
for(i=0;f=document.forms;i++)
f.onsubmit=zzz;
</script>
If you hit either submit button you'll get an alert box with
"a=Submit&b=Save&" in it. The resultant URL, however, will only have
one of them set. ie. "b=Save" or "a=Submit" but not both.
My question is... is it possible, in javascript, to view not what
form elements exist but what form variables will be submitted?
My goal is to adapt this into a bookmarklet that I can use on
arbitrary websites.