Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery slidedown() slideup() when radiobutton is clicked
    primarykey
    data
    text
    <p>I am very new to Javascript, and can't seem to find the information I'm looking for. I'm trying to make another div slide down when the "Yes" radio button is clicked, and slide back up when "No" is clicked. However, nothing is happening when I click either one. This is my current code:</p> <p><b>HTML:</b></p> <pre><code>&lt;div class="field"&gt; &lt;label for=""&gt;Apprentice&lt;/label&gt; &lt;div class="topRadio"&gt; &lt;input name="apprentice" group="apprentice" type="radio" value="Yes" onclick="dropbcitdown()"&gt; &lt;label for=""&gt;Yes&lt;/label&gt; &lt;input name="apprentice" group="apprentice" type="radio" value="No" onclick="pickbcitup()"&gt; &lt;label for=""&gt;No&lt;/label&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="field slidingdiv" id="doyouattend"&gt; &lt;label for=""&gt;Do you attend BCIT?&lt;/label&gt; &lt;div class="topRadio"&gt; &lt;input name="bcit" group="bcit" type="radio" value="Yes" onclick="droptransportationdown()"&gt; &lt;label for=""&gt;Yes&lt;/label&gt; &lt;input name="bcit" group="bcit" type="radio" value="No" onclick="picktransportationup()"&gt; &lt;label for=""&gt;No&lt;/label&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class ="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="field slidingdiv" id="doyouneed"&gt; &lt;label for=""&gt;Do you need ground transportation to city hall?&lt;/label&gt; &lt;div class="topRadio"&gt; &lt;input name="transportation" group="transportation" type="radio" value="Yes"&gt; &lt;label for=""&gt;Yes&lt;/label&gt; &lt;input name="transportation" group="transportation" type="radio" value="No"&gt; &lt;label for=""&gt;No&lt;/label&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p><b>Javascript</b></p> <pre><code>&lt;script&gt; function bcitDown() { $("#doyouattend").slideDown("slow" function() { $(this).css({ display: "inline"; }) }) } function bcitUp() { $("#doyouattend").slideUp("slow" function() { $(this).css({ display: "none"; }) }) } function transportationDown() { $("#doyouneed").slideDown("slow" function() { $(this).css({ display: "inline"; }) }) } function transportationUp() { $("#doyouneed").slideUp("slow" function() { $(this).css({ display: "none"; }) }) } &lt;/script&gt; </code></pre> <p>I have also tried doing it with the values of the radiobuttons, but I can't submit the for before they drop down. Unrelated, but the '' making a line break if anyone is wondering why that's happening. I have tried running this without that, and haven't had a different outcome. If I am making a glaring syntax error, or this ends up being some obvious solution that I totally missed, I'm sorry. I just feel that I've tried everything. NOTE: I have included JQuery.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload