Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > viewing the form variables that are being submitted

Reply
Thread Tools

viewing the form variables that are being submitted

 
 
yawnmoth
Guest
Posts: n/a
 
      05-01-2009
<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[i].name + '=' + e[i].value + '&';
alert(vars);
}

for(i=0;f=document.forms[i];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.
 
Reply With Quote
 
 
 
 
Jeremy J Starcher
Guest
Posts: n/a
 
      05-01-2009
On Fri, 01 May 2009 12:02:32 -0700, yawnmoth wrote:

[ Form and code snipped ]

> 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.


You might want to try reading this:

http://groups.google.com/group/comp....thread/thread/
e4859563aabaf768/dec455c027d3154c?q=serialize+form&lnk=ol&
 
Reply With Quote
 
 
 
 
Justin McConnell
Guest
Posts: n/a
 
      05-01-2009
On May 1, 12:02*pm, yawnmoth <(E-Mail Removed)> wrote:
> 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.


In any given form, only one input with type submit can be successful.
Only controls that are successful will be submitted as part of the
form data.

http://www.w3.org/TR/html401/interac...ssful-controls
 
Reply With Quote
 
SAM
Guest
Posts: n/a
 
      05-01-2009
Le 5/1/09 9:02 PM, yawnmoth a écrit :
> <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[i].name + '=' + e[i].value + '&';
> alert(vars);
> }
>
> for(i=0;f=document.forms[i];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.


Usually both (or all) submit buttons have same name, and it is the sent
value that gives the information about which one was clicked.

> My question is... is it possible, in javascript, to view not what
> form elements exist but what form variables will be submitted?


I think no.

Except
<input type=submit value="foo" onclick="alert(this.value)">

> My goal is to adapt this into a bookmarklet that I can use on
> arbitrary websites.


With which navigator ?

--
sm
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
newbie question - viewing form buttons submitted via 'post'? mr. gone Javascript 9 08-30-2009 12:22 AM
Form still being submitted despite being invalid =?Utf-8?B?TWFyayBQYXJ0ZXI=?= ASP .Net 4 07-25-2005 02:46 PM
How to get and save PDF submitted from FDF form? SWu ASP .Net 0 01-13-2004 03:02 AM
Form submitted Eric Shin ASP .Net 5 01-12-2004 08:40 PM



Advertisments