snipt

Ctrl+h for KB shortcuts

JavaScript

Move Gravity Form sub-labels above form inputs

1
2
3
4
5
6
7
8
jQuery('.ginput_container label').each(function(i,e){
    fielddesc = jQuery('<div>').append(jQuery(e).clone()).remove().html();
    jQuery(e).siblings('.ginput_container input:text').before(fielddesc); //moves sub label above input fields
    jQuery(e).siblings('.ginput_container select').before(fielddesc); //moves sub label above select fields (e.g. country drop-down)
    jQuery(e).siblings('.ginput_container .gfield_radio input').after(fielddesc); //keep label above radio buttons
    jQuery(e).siblings('.ginput_container .gfield_checkbox input').after(fielddesc); //keep label above checkboxes
    jQuery(e).remove();
});
https://snipt.net/embed/07fc7da23decee6d77be58c618472b2c/
https://snipt.net/raw/07fc7da23decee6d77be58c618472b2c/
07fc7da23decee6d77be58c618472b2c
js
JavaScript
8
2016-09-21T18:10:01
True
False
False
Feb 16, 2016 at 12:00 PM
/api/public/snipt/144263/
move-gravity-form-sub-labels-above-form-inputs
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nx">jQuery</span><span class="p">(</span><span class="s1">&#39;.ginput_container label&#39;</span><span class="p">).</span><span class="nx">each</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span><span class="nx">e</span><span class="p">){</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">fielddesc</span> <span class="o">=</span> <span class="nx">jQuery</span><span class="p">(</span><span class="s1">&#39;&lt;div&gt;&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">jQuery</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">clone</span><span class="p">()).</span><span class="nx">remove</span><span class="p">().</span><span class="nx">html</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">jQuery</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">siblings</span><span class="p">(</span><span class="s1">&#39;.ginput_container input:text&#39;</span><span class="p">).</span><span class="nx">before</span><span class="p">(</span><span class="nx">fielddesc</span><span class="p">);</span> <span class="c1">//moves sub label above input fields</span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">jQuery</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">siblings</span><span class="p">(</span><span class="s1">&#39;.ginput_container select&#39;</span><span class="p">).</span><span class="nx">before</span><span class="p">(</span><span class="nx">fielddesc</span><span class="p">);</span> <span class="c1">//moves sub label above select fields (e.g. country drop-down)</span> </span><span id="L-5"><a name="L-5"></a> <span class="nx">jQuery</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">siblings</span><span class="p">(</span><span class="s1">&#39;.ginput_container .gfield_radio input&#39;</span><span class="p">).</span><span class="nx">after</span><span class="p">(</span><span class="nx">fielddesc</span><span class="p">);</span> <span class="c1">//keep label above radio buttons</span> </span><span id="L-6"><a name="L-6"></a> <span class="nx">jQuery</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">siblings</span><span class="p">(</span><span class="s1">&#39;.ginput_container .gfield_checkbox input&#39;</span><span class="p">).</span><span class="nx">after</span><span class="p">(</span><span class="nx">fielddesc</span><span class="p">);</span> <span class="c1">//keep label above checkboxes</span> </span><span id="L-7"><a name="L-7"></a> <span class="nx">jQuery</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">remove</span><span class="p">();</span> </span><span id="L-8"><a name="L-8"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
forms, gravity

JavaScript

Restrict Weekends and Past Dates in jQuery DatePicker

1
2
3
4
$('.datepicker').datepicker({
    minDate: 0,    
    beforeShowDay: $.datepicker.noWeekends 
});
https://snipt.net/embed/c921269612c91be07ca88d3e7958eac7/
https://snipt.net/raw/c921269612c91be07ca88d3e7958eac7/
c921269612c91be07ca88d3e7958eac7
js
JavaScript
4
2016-10-01T04:20:53
True
False
False
Feb 16, 2016 at 11:15 AM
/api/public/snipt/144211/
restrict-weekends-and-past-dates-in-jquery-datepicker
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.datepicker&#39;</span><span class="p">).</span><span class="nx">datepicker</span><span class="p">({</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">minDate</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">beforeShowDay</span><span class="o">:</span> <span class="nx">$</span><span class="p">.</span><span class="nx">datepicker</span><span class="p">.</span><span class="nx">noWeekends</span> </span><span id="L-4"><a name="L-4"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
forms, jquery

C#

HTML Select list to open a custom URL based on selected value

1
2
3
4
5
6
<select name="sortby"  onchange="window.location = '@onChangeUrl' + encodeURI(this.value)">
    @foreach(KeyValuePair<string, int> option in SPModel.SortOptions)
    {
        <option value="@option.Value">@option.Key</option>
    }									
</select>
https://snipt.net/embed/1e15e79ff0d93227ae62cff6330ebea3/
https://snipt.net/raw/1e15e79ff0d93227ae62cff6330ebea3/
1e15e79ff0d93227ae62cff6330ebea3
csharp
C#
7
2016-09-22T08:40:25
True
False
False
Feb 05, 2014 at 07:22 PM
/api/public/snipt/111269/
html-select-list-to-open-a-custom-url-based-on-selected-value
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="p">&lt;</span><span class="k">select</span> <span class="n">name</span><span class="p">=</span><span class="s">&quot;sortby&quot;</span> <span class="n">onchange</span><span class="p">=</span><span class="s">&quot;window.location = &#39;@onChangeUrl&#39; + encodeURI(this.value)&quot;</span><span class="p">&gt;</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">@foreach</span><span class="p">(</span><span class="n">KeyValuePair</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">,</span> <span class="kt">int</span><span class="p">&gt;</span> <span class="n">option</span> <span class="k">in</span> <span class="n">SPModel</span><span class="p">.</span><span class="n">SortOptions</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">&lt;</span><span class="n">option</span> <span class="k">value</span><span class="p">=</span><span class="s">&quot;@option.Value&quot;</span><span class="p">&gt;</span><span class="n">@option</span><span class="p">.</span><span class="n">Key</span><span class="p">&lt;/</span><span class="n">option</span><span class="p">&gt;</span> </span><span id="L-5"><a name="L-5"></a> <span class="p">}</span> </span><span id="L-6"><a name="L-6"></a><span class="p">&lt;/</span><span class="k">select</span><span class="p">&gt;</span> </span></pre></div> </td></tr></table>
forms, html, razor
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.