Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling Function in Jquery
    primarykey
    data
    text
    <p>I have this dropdown (selectbox) HTML code in a web page, which i am storing it in a Cookie using Jquery</p> <pre><code>&lt;select onchange="if (this.value != '') {Add_Search_Param('f-' + this.value.split('|')[1], this.value.split('|')[0]); Refine();}"&gt;&lt;option value=""&gt;Find by LENGTH&lt;/option&gt;&lt;option value="185|14 inch"&gt;14 inch (31)&lt;/option&gt;&lt;option value="186|11 inch"&gt;11 inch (39)&lt;/option&gt;&lt;option value="187|8 inch"&gt;8 inch (38)&lt;/option&gt;&lt;/select&gt; </code></pre> <p>i have following code which reads the above select tag using jquery and display same dropdown on that page. I have also set one function to select tag which i got from cookie using jquery but the problem is that the function is not getting called when i change option in drop down. please help me</p> <pre><code>&lt;div id="content"&gt;&lt;/div&gt; &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var refineResults = true; function Add_Search_Param(param, value, append, forceRefine) { alert("Good"); if (param == 'pricerange') { value = value.split('-'); Add_Search_Param('minprice', value[0]); Add_Search_Param('maxprice', value[1], append, forceRefine); return; } if (SearchParams.indexOf(param + '=') != -1) { if (append) { SearchParams = SearchParams.replace(new RegExp(param + '=([^&amp;]*)'), param + '=$1' + escape(value)); } else { SearchParams = SearchParams.replace(new RegExp(param + '=([^&amp;]*)'), param + '=' + escape(value)); } } else { SearchParams = SearchParams + '&amp;' + param + '=' + escape(value); } if (param != 'page') { Add_Search_Param('page', 1); } if (forceRefine) { Refine(); } } function Refine() { if (SearchParams.substr(0, 1) == '&amp;') { SearchParams = SearchParams.substr(1); } location.href = location.pathname + '?' + SearchParams; return false; } function OpenNewWindow(url, width, height) { window.open(url, null, 'top=10,left=10,menubar=0,resizable=1,scrollbars=1,width=' + width + ',height=' + height) } function OnSubmitSearchForm(event, form) { var additionalSearch = v$('additionalsearch'); if (additionalSearch) { if (additionalSearch.value != 'Search Within') { Add_Search_Param('search', ' ' + additionalSearch.value, true); } } if (refineResults) { CancelEvent(event); return Refine(); } else { return true; } } function OnKeyDownPageInputBox(evt, inputBox) { if (IsReturnKey(evt)) { Add_Search_Param('page', inputBox.value); Refine(); return false; } } function hello() { alert("Hello"); } function getCall() { function parseHtml(document) { var k = 0; var s = 0; var count = $(document).find('select').each(function() { var str = $(this).attr('onchange'); if (str.indexOf("Add_Search_Param('f-' + this.value.split('|')[1],") != -1) { createCookie("onchangecall", $(this).attr('onchange')); createCookie("options", $(this).html()); //alert($(this).html()); k = 1; } else { s = 1; } }).length; if (s == 1 &amp;&amp; k == 0) { $(function() { var atr = 'onchange="' + readCookie("onchangecall") + '; Refine();}"'; $("#content").append('&lt;select id="sel" onchange="fly()"&gt;' + readCookie("options") + '&lt;/select&gt;'); $("#sel").attr("onchange", atr); alert($("#sel").attr("onchange")); }); } } $.ajax({ type: "GET", url: "", dataType: "html", success: parseHtml }); function createCookie(name, value) { var expires = ""; document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i &lt; ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } } getCall(); &lt;/script&gt; &lt;input type="image" src="/v/vspfiles/assets/images/image.jpg" style="float:left; margin:0 0 0; font-size: 13px; font-family: arial;"/&gt; </code></pre>
    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.
    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