user899641
user899641

Reputation: 351

Hide/Show Form Elements Not Working on Android App

I'm trying to create an interactive form. Your selections determine the next questions that appear. I'm using jQuery Mobile and it is working fine on the PC using Dreamweaver but when I build to Android the java scripts aren't working. This seems like simple code so I'm not sure why it's not working on Android. Can someone tell me where I'm going wrong?

Here's the code:

Javascript:

function toggle_visibility(id) {
   var e = document.getElementById(id);
   if(e.style.display == 'block')
      e.style.display = 'none';
   else
      e.style.display = 'block';
}

HTML:

<div id=SkillSet data-role="fieldcontain">
      <fieldset data-role="controlgroup" data-type="horizontal">
        <legend>Skill Set:</legend>
        <a onclick="toggle_visibility('AV');"><input type="checkbox" name="SkillSet" id="SkillSet_0" class="custom" value="" /></a>
        <label for="SkillSet_0">AV</label>
        <a onclick="toggle_visibility('IT');"><input type="checkbox" name="SkillSet" id="SkillSet_1" class="custom" value="" /></a>
        <label for="SkillSet_1">IT</label>
      </fieldset>
    </div>


   <div id="IT" style="display:none">
    <hr>

    Blah Blah Blah     
</div>

Upvotes: 2

Views: 1981

Answers (2)

Coomie
Coomie

Reputation: 4868

This is an interesting one:

Android web DOES support display:none And javascript And jQuery mobile isn't being used

I think it might be because you have an anchor tag around your input. Try putting the onclick event on the checkbox or put something else in the anchor.

EDIT: Or could it be that there are multiple elements with the same id? Ids are supposed to be unique...

Upvotes: 1

mowwwalker
mowwwalker

Reputation: 17362

Try attaching the functions to window.

window.toggle_visibility = function(id) {
   var e = document.getElementById(id).style.display;
   e=="block" ? e="none" : e="block";
}

Although I'm sure there is something simpler with jquery for something like that.

Also, why are your check boxes inside of a tags?

Upvotes: 0

Related Questions