niyassulaiman Posted October 29, 2017 Share Posted October 29, 2017 In this code, this is always redirecting/forwarding to particular page. Could you please help me to navigate to different page on certain condition. Suppose if the value of $product_array is greater than "200" go to one particular page, otherwise to second page. $( "#search" ).autocomplete( { minLength: 0, source: <?php echo $product_array;?>, focus: function( event, ui ) { $( "#search" ).val( ui.item.label ); return false; }, select: function( event, ui ) { $( "#search" ).val( ui.item.label); $("#hsearch").val( ui.item.value ); var url = '<?php echo Yii::app()->params["productURL"]. "'+ ui.item.value +'"."?lang=$lang"; ?>'; window.location.replace(url); } }); Quote Link to comment https://forums.phpfreaks.com/topic/305495-condition-with-autocomplete/ Share on other sites More sharing options...
requinix Posted October 29, 2017 Share Posted October 29, 2017 var url = 'params["productURL"]. "'+ ui.item.value +'"."?lang=$lang"; ?>';That is one URL. Use an if (in Javascript) to use a different URL if the ui.item.value > 200. Try it. If you have problems, post what you've come up with. Quote Link to comment https://forums.phpfreaks.com/topic/305495-condition-with-autocomplete/#findComment-1553214 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.