开发者

Select input value from two different forms in one page using mootools

开发者 https://www.devze.com 2023-03-25 22:20 出处:网络
I have two forms with different values in one page. I want get input value of the form that user clicks on it\'s submit button, using mootools code.

I have two forms with different values in one page.

I want get input value of the form that user clicks on it's submit button, using mootools code.

Mootools code most work for two forms, as same:

 <form class="cart_form" >  
            <input type="hidden" name="order_code" value="KWL-hgy" />
            <input type="hidden" name="price" value="40000" />
            <input type="hidden" name="name" value="modeling" />    
            <label>KWL-hgy: <input class="center" type="text" name="qty" value="2" size="3" ></label>  
            <input type="submit" name="submit" value="Add to cart" />  
        </form>

 <form class="cart_form" >  
            <input type="hidden" name="order_code" value="KWL-JFE" />
            <input type="hidden" name="price" value="12000" />
            <input type="hidden" name="name" value="php" />    
            <label>KWL-JFE: <input class="center" type="text" name="qty" value="1" size="3" ></label>  
            <input type="submit" name="submit开发者_如何转开发" value="Add to cart" />  
        </form>


you could do it somehow like this:

$$('form.cart_form').addEvent('submit', function(e){
    this.getChildren().each(function(el){
        alert(el.get('name') + ': ' + el.get('value'));
    });
});

this will fire an event as soon as a form with the class chart_form is submited and loop through all the form's children.

0

精彩评论

暂无评论...
验证码 换一张
取 消