Javascript get form action

Discussion in 'JavaScript' started by Silver89, Nov 19, 2008.

  1. #1
    Is there a way to get the action of an un specified form in javascript?

    I want to run through a few websites and get tthe action from forms so this would be helpfull.

    Thanks
     
    Silver89, Nov 19, 2008 IP
  2. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
       <script type="text/javascript">
    
        var formsArray = document.getElementsByTagName("form");
    
        for (i=0; i<formsArray.length; i++)
        { 
          document.write('form ' + (i+1) + ' action: ' +  ' ' + formsArray[i].getAttribute('action') + '<br>\n');
        }
    
       </script>
    
    Code (markup):
     
    LogicFlux, Nov 19, 2008 IP