submitting form on image click

后端 未结 4 898
無奈伤痛
無奈伤痛 2021-01-12 12:50

I have multiple images inside one form. Depending on the image clicked a specific value should be sent with a POST.

Can this be done without javascript? (I use jquer

4条回答
  •  太阳男子
    2021-01-12 13:24

    The safe approach to this problem is to give the inputs unique names and see which one sends coordinates.

    
    
    

    Only the successful control will send any data. So test to see if submit_blue.x has a value, then test if submit_red.x has one.

    There is no need to involve JavaScript at all.

    Alternatively, use regular submit buttons instead of server side image maps.

    
    

    … keeping in mind that this will break in old-IE as it doesn't support

提交回复
热议问题