Problem with my "switch case"
Hello,
- <form>
- <select size="1" name="categories" class="texte">
- <option value="0">-- catégories --</option>
- <option value="1">lion</option>
- <option value="2">butterfly</option>
- </select>
- <div id="options">
- <p class="lion" style="display: none;">
- <input type="text" size="8" value="lion"/>
- </p>
- <p class="butterfly" style="display: none;">
- <input type="text" size="8" value="butterfly"/>
- </p>
- </div>
- </form>
- $(document).ready(function(){
- $("select[name='categories']").change(function(){
- var valeur=parseInt($(this).attr("value"));
- switch(valeur){
- case(0):$("div#options p").hide();break;default:;
- case(1):$("div#options p.lion").show();break;
- case(2):$("div#options p.butterfly").show();break;
- };
- });
- });
My problem is I'm missing something in my code.
When I select Lion, then Butterfly, Lion does not clear, it should be replaced by my choice Butterfly.I wonder if I'll have to like that.It should be a Lion is hiding when Butterfly is chosen. Butterfly or hiding when Lion is chosen.But there is also another problem is that the position of my tags is considered <P></P> and I do not want to shift, one takes the place of another.It's simple in theory but in practice 
Thanks