செவ்வாய், 20 ஜூன், 2017

Light on/off using java script

<html>
<body>

<h2>What Can JavaScript Do?</h2>

<p>JavaScript can change HTML attributes.</p>

<p>In this case JavaScript changes the src (source) attribute of an image.</p>

<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button>

<img id="myImage" src="pic_bulboff.gif" style="width:100px">

<button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button>

</body>
</html>

Hide and then show an image using Javascript

<script>  
function showhide() {  
document.getElementById('someimage').style.visibility="hidden";   
        }  
</script>  
At the moment I am able to hide the image, however then I have no way to show it again. How can I hide and then be able to show an image when clicking a button using javascript?
Here's the button:
<body>  
<input type="button" onclick="showhide()" />   
</body>  
share

2  
@Guy Maybe OP isn't using some bloated library? – PeeHaa Feb 25 '13 at 21:40
    
@PeeHaa, perhaps. – gmaliar Feb 25 '13 at 21:43
    
Have you heard of jQuery.toggle()? api.jquery.com/toggle will solve the problem, I deeply suggest using it for simple problems such as these as all the code implementation is done for you. – gmaliar Feb 25 '13 at 21:44
2  
This definitely is a beginner's question, but it's not deserving the downvotes IMHO... – alexander.biskop Feb 25 '13 at 21:46
    
@alexander.biskop Agreed. It's got enough info to know the context, it's got code of what he has so far, and a simple question about how to take things to the next step. It's a well asked question! – Alex Wayne Feb 25 '13 at 21:52
Simply check what the current state is, and then act accordingly.
function showhide() {
    var img = document.getElementById('someimage');
    if (img.style.visibility === 'hidden') {
        // Currently hidden, make it visible
        img.style.visibility = "visible";
    } else {
        // Currently visible, make it hidden
        img.style.visibility = "hidden";
    }
}

And a quick note about jQuery to all those suggesting it.
For simple things like this, there is no need to include a big DOM manipulation library. If you are doing a lot of DOM manipulations like this in a more complex application, then jQuery starts to make more sense to include.
But it's also important to understand what jQuery is doing for you under the hood when you use it.
share

The wonders of jQuery - http://jsfiddle.net/PbG3t/
$(function() {
    $('#button').click(function() {
        $('#someimage').toggle();
    });
 });
share

If you are using jQuery, you can use the (.toggle) method which simplifies things a lot:
$('#someimage').toggle();
If you want to stick with a hand-crafted solution, I guess your code is actually missing the deciding bit that sets the element's visibility back to visible. Try:
<script>  
  function showhide() {
      var element = document.getElementById('someimage');
      element.style.visibility = element.style.visibility == 'visible' 
          ? 'hidden' 
          : 'visible';   
  }  
</script>

Difference between DSL and ADSL



Question
What's the difference between a house and a home? — Hamza, Pakistan
Answer
The definitions of these two words are similar, as shown below. 
house:  a building in which a person or a family lives 
home:  a house or apartment where a person or a family lives
The main difference between them is that house is concrete. House refers to a building in which someone lives. In contrast, a home can refer either to a building or to any location that a person thinks of as the place where she lives and that belongs to her. A home can be a house or an apartment, but it could also be a tent, a boat, or an underground cave. 
A home can even be something abstract, a place in your mind. When you say, “Let’s go home,” you are probably not talking simply about going to the physical structure where you live. You are talking about being in the special place where you feel most comfortable and that belongs to you.

Difference between DSL and ADSL
Key Difference: DSL stands for ‘digital subscriber line’. It is a broad term that a digital high-speed data connection over telephone lines. ADSL stands for ‘Asymmetric digital subscriber line’. It is a type of DSL technology which has different upload and download speeds.
http://www.differencebetween.info/sites/default/files/images_articles_d7_1/internet_0.jpgToday, technology has come to such a place that nearly everything is dependent on technology. However, most of the technology today would be useless without internet. This is where DSL and ADSL come in.
DSL stands for ‘digital subscriber line’. It is a broad term that a digital high-speed data connection. It utilized the same writing as a regular telephone line, however it can also be modified to use cable wiring.
As telephone line only transmit a limited spectrum of signals, i.e. between 20 Hertz to 20,000 Hertz, the frequencies that transmit voice, DSL can utilize the remaining frequencies to transmit data.  In order to do this, the consumer typically needs to install a DSL filter, also known as a splitter, on the telephone line which separates the data part from the telephony part. Consumers also need a DSL modem which converts the signal sent on the telephone line to a usable data signal. 
The bit rate of consumer DSL services typically ranges from 256 kbit/s to over 100 Mbit/s downstream, i.e. towards the consumer. However, the speed decreases the further away the customer is located from the provider. Hence, one customer may get  a speed of 100 Mbit/s, whereas the other may only get 256 kbit/s.
http://www.differencebetween.info/sites/default/files/images_articles_d7_1/dsl-adsl-setup.jpgADSL stands for ‘Asymmetric digital subscriber line’. It is a type of DSL technology; in fact it is the most common and popular type of DSL technology used. ADSL transmits data over copper telephone lines, which is generally faster than a conventional voiceband modem in DSL.
ADSL is named as such because the Bandwidth and bit rate are asymmetric; what this means is that they are greater when geared downstream, i.e. towards the customer, rather than upsteam, i.e. geared towards the provider. Hence, it results in a greater download speed than upload speeds.
However, DSL and ADSL have been steadily falling out of favor and are quickly being labeled as outdated technology. It is being replaced by cable modem, fiber, wireless, and satellite, all which are generally faster in comparison and hence preferable. Additionally, telephone lines themselves are falling into disuse due to the advent of cellular technology. Despite of this, ADSL is still technically considered to be the most commonly utilized technology for broadband internet access, especially in some parts of the world. However, for how long will that be is anyone’s guess.
Comparison between DSL and ADSL:

DSL
ADSL
Type of
Network connection
DSL Network connection
Stands for
Digital Subscriber Line
Asymmetric Digital Subscriber Line
Provides
Internet connection
Internet connection
Signal
Sends signal over telephone wires
Sends signal over telephone wires
Devices needed
  • Splitter or DSL filter to separate the data part from the telephony part
  • DSL modem to convert the signal into a data signal
  • Splitter or DSL filter to separate the data part from the telephony part
  • DSL modem to convert the signal into a data signal
Network Speed
256 kbit/s to over 100 Mbit/s
256 kbit/s to over 100 Mbit/s
Download speed and Upload speed
Both are usually the same
Both are different. Down speed is much faster than Up speed.