Pass information through jQuery in Joomla error -


my jquery code throwing error in joomla, it's supposed take text textbox , insert @ end of url has been specified after button has been clicked.

jhtml::_('behavior.framework', true);  var url = 'https://test.com/storefrontcommerce/search.do;jsessionid=cd66cbfcc5658d6c9327aa269764ebb2?searchtype=keyword&keyword='; $('button').click(function() {       window.location.replace(url + $('#textbox').val()); }); 

here error message receive: parse error: syntax error, unexpected t_var in /home/dival/public_html/templates/proposed/index.php on line 35

this index.php file in template i'm using:

<?php defined('_jexec') or die;  /**  * template joomla! cms, created artisteer.  * see readme.txt more details on how use template.  */  // load jquery, if not loaded before   if(!jfactory::getapplication()->get('jquery')){      jfactory::getapplication()->set('jquery',true);      $document = jfactory::getdocument();      $document->addscript(juri::root() . "templates/template_name/js/jquery.js");   }  require_once dirname(__file__) . directory_separator . 'functions.php';  // create alias $this object reference: $document = $this;  // shortcut template base url: $templateurl = $document->baseurl . '/templates/' . $document->template;  artx::load("artx_page");  // initialize $view: $view = $this->artx = new artxpage($this);  // decorate component artisteer style: $view->componentwrapper();  jhtml::_('behavior.framework', true); jhtml::_('jquery.framework');  var url = 'https://test.com/storefrontcommerce/search.do;jsessionid=cd66cbfcc5658d6c9327aa269764ebb2?searchtype=keyword&keyword='; $('button').click(function() {       window.location.replace(url + $('#textbox').val()); });  ?> 

i absolutely cringed when saw artx::load. hope had reason go artisteer template.

anyway on-topic. have added jquery code inside tags. can't happen 2 different languages. can use php (joomla api methods in case) execute jquery so:

$js = " $('button').click(function() {            var url = 'https://test.com/storefrontcommerce/search.do;jsessionid=cd66cbfcc5658d6c9327aa269764ebb2?searchtype=keyword&keyword=';            window.location.replace(url + $('#textbox').val());         });       "; $document = jfactory::getdocument(); $document ->addscriptdeclaration($js); 

notice have put thr url variable inside click function it's not global variable.

hope helps


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -