Help with HTML (button with area and input)

0

Good evening, everyone. The code is this:

<form action="/teste.php" method="get">

    <map name="image-map">
        <area target="" alt="" title="" coords="210,233,541,508" shape="rect">
    </map>

    <div>
        <font face="verdana" color="white">Player: </font>
        <input type="text" name="nome_player" maxlength="15"><br>
    </div>

    <div>
        <img src="imagens/img_inicial.png" alt="circulo_" class="circulo" usemap="#image-map"/>
    </div>

</form>

This area within the map would work as a button, but I just put it in a href, but I needed it to work as an input (submit), to do the form's action ... Anyone know how to help me?

    
asked by anonymous 03.07.2018 / 01:37

1 answer

0

Try this way, in href you call the function

href="javascript:document.getElementById('formID').submit();"

<form action="/teste.php" method="get" id="formID">

        <map name="image-map">
            <area target="" alt="" title="" coords="210,233,541,508" shape="rect" href="javascript:document.getElementById('formID').submit();">
        </map>
    
        <div>
            <font face="verdana" color="white">Player: </font>
            <input type="text" name="nome_player" maxlength="15"><br>
        </div>
    
        <div>
            <img src="http://unsplash.it/600/600"alt="circulo_" class="circulo" usemap="#image-map"/>
        </div>
    
    </form>

Another way to do without href doing a onClick="myform.submit();"

<form name="myform" action="/teste.php" method="post>
    ... campos do form ....
    <area onClick="myform.submit();" nohref target="" alt="" title="" coords="210,233,541,508" shape="rect">
</form>
    
03.07.2018 / 01:55