About document.getElementID? Explain giving one example.

This was asked by a interviewer when i said that i know
some JavaScript.




Answers were Sorted based on User's Feedback



About document.getElementID? Explain giving one example. This was asked by a interviewer when i..

Answer / negi

using this u can access any html elements by its id.Here we
are going to access <tr> by its id("abc").when we click on
submit button javascript execute and <tr> will not be displayed.
<html>
<head>
<title>xxx</title>
<script language="javascript" type="text/javascript">
function change()
{
document.getElementById("abc").style='none';
return true;
}
</script>
</head>
<body>
<table>
<tr id="abc">
<td>you are great</td>
<td><input type="submit" name="submit" value=""
onClick="return change();"/></td>
</tr>
</table>
</body>
</html>

Is This Answer Correct ?    17 Yes 6 No

About document.getElementID? Explain giving one example. This was asked by a interviewer when i..

Answer / kishore.gsgs

using this u can access any html elements by its id.Here we
are going to access <input> textbox by its id("abc").when we
click on
submit button javascript execute and <tr> will not be displayed
<html>
<head>
<script type="text/javascript">

function change()
{
alert("success");
alert(document.getElementById("kishore").value);
}
</script>

</head>
<body>
<input type="text" id="kishore">
<input type="button" name="submit" value="submit"
onClick="change()"/>
</body>
</html>

Is This Answer Correct ?    7 Yes 3 No

Post New Answer




More JavaScript Interview Questions

hi i want validations for two drop down lists. when user enter to second list by skipping first list alert box should appear. <HTML><HEAD> <TITLE>drop down validation</TITLE> <script type="text/javascript"> function validateForm(){ if(document.ItemList.Item.selectedIndex==0) { alert("Please select item from first list."); document.ItemList.Item.focus(); return false; } return true; } </SCRIPT> </HEAD> <BODY> Please choose an item from the drop down menu: <form name="ItemList" method="post" action="asp.html" onsubmit="validateForm()"> <table width="100%" border="0"> <tr> <td width="135">Choose a username: </td> <td> <select name="Item"> <option value selected> SELECT </option> <option value>Apples</option> <option value>Oranges</option> </select> <table width="100%" border="0"> <tr> <td width="135">Choose a username: </td> <td> <select name="Item" onclick="validateForm()"> <option value selected> SELECT </option> <option value>Apples</option> <option value>Oranges</option> </select> <input type="submit" name="Submit" value="Submit"> </td></tr></table></form> </BODY> </HTML> please any body help me thanks

0 Answers  


<script type="text/javascript"> function dispValue(e) { v = function (s) { return e.name + ': ' + s } if (e.type == "") return v(e.checked ? "" : ""); else return v(e.value); }

0 Answers  


program showing string concatenation?

4 Answers  


coding of java scripts

0 Answers   Oracle,


how can we generate alert message without referashing page in asp.net with language vb.net and script use in java script .means with out referash the page message in java alert

0 Answers   NIC,






How do you send a message to the browser in JavaScript?

3 Answers   Four soft, Vsys,


Are there any iphone Institutes which also train iphone automation testing in Hyderabad?

0 Answers  


Write a main method that prompts the user to enter the starting population, birth and death rates, and the number of years. The input birth and death rates cannot be negative, the starting population cannot be less than 2, and the number of years greater than 0. If the user enters an invalid value, this program will prompt user to re-enter the value until a valid value has been read. When all input values are valid, call on the methods above to compute estimated population and print result.

0 Answers   Wipro,


java pgm for reads a file(text file) and removes all the spaces then the text and write this back into the same file. e.g: (Input) _______ chennai is fourth biggest city in india. (output) _______ chennaiisfourthbiggestcityinindia.

0 Answers  


Write a program in Java to display the IP address of the local and remote machine.

0 Answers   Annamalai University,


Can you call a Java Applet using a JavaScript function?

2 Answers   HCL, Satyam,


how can we retrieve value from one database server and store them another database server using sql server code

0 Answers   HP,






Categories