Jump to content
PlayGames63

Pegar o value de um input quando clicar

Recommended Posts

PlayGames63

Bom estou a fazer um quiz, e no html eu tenho o seguinte código

<input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1">

só que no js eu não estou a conseguir que quando a pessoa clique na imagem ele consiga pegar o value para no caso saber em que imagem a pessoa clicou alguém sabe como eu posso faze-lo?

Obrigado.

Share this post


Link to post
Share on other sites
Zex

<script>

function processar1 (botao)
  {
  alert( botao.value )
  }

function processar2 (arg)
  {
  alert( arg )
  }

</script>



<body>

<input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1" onclick="processar1(this)">

<input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1" onclick="processar2(1)">

</body>

</html>

 

  • Vote 1

Share this post


Link to post
Share on other sites
PlayGames63
Em 24/06/2019 às 12:35, Zex disse:


<script>

function processar1 (botao)
  {
  alert( botao.value )
  }

function processar2 (arg)
  {
  alert( arg )
  }

</script>



<body>

<input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1" onclick="processar1(this)">

<input type="image" id="submit" class="grupos" src="imgs/t.png" name="p1" value="1" onclick="processar2(1)">

</body>

</html>

Muito obrigado!

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.