Jump to content

JavaScript!? How to put id of the element type button into variable!?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Stasonix

Stasonix

    Learning Programmer

  • Members
  • PipPipPip
  • 82 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal
for example:
<script language="javascript">

 

function proverka()

 {

   

  if (document.forms.stas('otv_a').id=="true")

   {

    alert("SUPPER!");

        };

  

  };

 

</script>
and element on form with id:
<FORM name="stas">

 <INPUT type="button" value="Capitan" name="otv_a" id="true" onClick="proverka();">

 </FORM>


#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java

<html>

<head>

	<script type="text/javascript">

		function something(id){

			alert(id);

		}

	</script>

	<title>title</title>

</head>

<body>

	<input type="button" id="button1" value="click" onclick="something(this.id)"/>

	<input type="button" id="button2" value="click" onclick="something(this.getAttribute('id'))"/>

</body>

</html>






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users