i have a modal form displaying a table created by calling a php form      function search()     {         xmlhttp= new XMLHttpRequest();         xmlhttp.open("GET","searchitem.php?id="+document.getElementById("stext").value,false);         xmlhttp.send(null);         document.getElementById("d1").innerHTML=xmlhttp.responseText;         document.getElementById("d1").style.visibility='visible';     }   searchitem.php creates table from the searched value.  i want to click  BUTTON in a row to select the values.  &lt;script&gt;     var table = document.getElementById('sTable');     for(var i = 1; i &lt; table.rows.length; i++)     {         table.rows[i].onclick = function()         {              //rIndex = this.rowIndex;              document.getElementById("sitemno").value = this.cells[0].innerHTML;              document.getElementById("sdesc").value = this.cells[1].innerHTML;         };     }  &lt;/script&gt;
112
I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off.  This happens on page ready and works just fine.  The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won't have the event bound.  I have found this plugin (), but before I add another 5k to my pages with a plugin, I want to see if anyone knows a way to do this, either with jQuery directly or by another option.
43780
I want to pass the java-script value to controller.I am using repeat on VF page.  VF page      &lt;apex:repeat value="{!listAdj}" var="Adj" id="hrs"&gt;       &lt;td&gt;&lt;div class="requiredInput"&gt;&lt;div class="requiredBlock"&gt;&lt;/div&gt;     &lt;apex:inputField id="decimal" value="{!Adj.Hours_Decimal__c}" onchange="setHidden5(this);" &gt;       &lt;/apex:inputField&gt;     &lt;/div&gt;&lt;/td&gt;             &lt;apex:inputField id="hours" value="{!Adj.Hours__c}" /&gt; &lt;apex:inputField id="decimal" value="{!Adj.Hours_Decimal__c}" onchange="setHidden5(this);"/&gt;              &lt;/apex:repeat&gt;   Javascript code  function setHidden5(element){     //split the id of the inputField by ':' and then use the 5th index in the array to exact position of the inputField in the apex:repeat.   var idArray = element.id.split(':');     var hiddenRep1 =document.getElementById("thePage:form:hrs:hrs:"+idArray[4]+":decimal");          var hiddenRep2 = document.getElementById("thePage:form:hrs:hrs:"+idArray[4]+":hours");       if(element.value.length &gt;=1){        document.getElementById("thePage:form:hrs:hrs:"+idArray[4]+":hours").disabled = true; **hiddenRep2.value=hidden1.value;**                }                             }     }   I want to pass the hiddenRep2.value to controller.How to pass that. Hidden2.value is same as hidden1.value + some addition subtraction.i dont know how to pass that value. Can someone me sort out this.  Thanks
46641
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady); var listTitle = []; var listUrl = []; var listIsActive = []; var listOrder = [];  function sharePointReady(){ var siteUrl = mysite;     var clientContext = new SP.ClientContext(siteUrl); var oList = clientContext.get_web().get_lists().getByTitle('Privacy Statements');  var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml(''); this.collListItem = oList.getItems(camlQuery);  clientContext.load(collListItem);  clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));         }    function onQuerySucceeded(sender, args) {  var listItemEnumerator = collListItem.getEnumerator();   while (listItemEnumerator.moveNext()) {     var oListItem = listItemEnumerator.get_current();     listTitle.push(oListItem.get_item('Title'));     listUrl.push(oListItem.get_item('PrivacyStatementUrls').get_url());      listIsActive.push(oListItem.get_item('IsActive'));     listOrder.push(oListItem.get_item('SortOrder'));    } sessionStorage.setItem('Title', JSON.stringify(listTitle)); sessionStorage.setItem('Url', JSON.stringify(listUrl)); sessionStorage.setItem('IsActive', JSON.stringify(listIsActive)); sessionStorage.setItem('Order', JSON.stringify(listOrder)); var retrievedTitle = sessionStorage.getItem("Title"); var arTitle = JSON.parse(retrievedTitle); var retrievedUrl = sessionStorage.getItem("Url"); var arUrl = JSON.parse(retrievedUrl); var retrievedIsActive = sessionStorage.getItem("IsActive"); var arIsAct = JSON.parse(retrievedIsActive); var retrievedOrd = sessionStorage.getItem("Order"); var arOrd = JSON.parse(retrievedOrd);  var test = '' for(x=0; x&lt;arTitle.length+1;x++) {      for(i=0; i&lt;arTitle.length+1;i++)     {          if(arIsAct[i] == true){             if(arOrd[i] == x){                 test +='&lt;a href="'+arUrl[i]+'"&gt;'+arTitle[i]+'&lt;/a&gt;&lt;br&gt;';             }            }      } }  document.getElementById('test').innerHTML = test; }  function onQueryFailed(sender, args) {  alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); }   I am trying to use caching with sessionstorage when getting items from a list, so it doesn't have to keep querying the list over and over again. It can just check with the sessionstorage and if its in the list there is no need to get the item but if its not in sessionstorage get the item from the list. I am not sure how to do this, my code above shows my attempt
105844
In a lightning component I display a list of articles (Article__c custom object) so I ca see, for example, the name of the article, the price, and a button that I'd like redirect to another component which display the details of the article selected.   For now I'm just trying to get the id of the article, in a basic alert in javascript, but I doesn't work : it says the id is null.   Here is a part of the component :  &lt;aura:handler name="init" value="{!this}" action="{!c.doInit}" /&gt; &lt;aura:attribute name="wrappers" type="ListeArticlesWrapper" /&gt; &lt;aura:attribute name="articles" type="Article__c" /&gt;  &lt;aura:attribute name="Detail" type="String"/&gt; &lt;aura:registerEvent name="navigate" type="c:NavigateToDetail"/&gt;  &lt;div class="page"&gt;     &lt;h1&gt;Liste des articles&lt;/h1&gt;     &lt;div class="slds"&gt;         &lt;table class="slds-table slds-table--bordered slds-table--cell-buffer"&gt;             &lt;thead&gt;                 &lt;tr class="slds-text-heading--label"&gt;                     &lt;th scope="col" class="head"&gt;&lt;/th&gt;                     &lt;th scope="col" class="head"&gt;Nom&lt;/th&gt;                     &lt;th scope="col" class="head"&gt;Type&lt;/th&gt;                     &lt;th scope="col" class="head"&gt;Prix&lt;/th&gt;                     &lt;th scope="col" class="head"&gt;&lt;/th&gt;                 &lt;/tr&gt;             &lt;/thead&gt;             &lt;tbody&gt;                 &lt;aura:iteration items="{!v.wrappers}" var="wrap"&gt;                     &lt;tr&gt;                         &lt;td class="cell"&gt;                             &lt;ui:inputCheckbox value="{!wrap.selected}" /&gt;                         &lt;/td&gt;                         &lt;td class="cell"&gt;                            &lt;ui:outputText value="{!wrap.art.Name}" /&gt;                         &lt;/td&gt;                         &lt;td class="cell"&gt;                             &lt;ui:outputText value="{!wrap.art.Type__c}" /&gt;                         &lt;/td&gt;                         &lt;td class="cell"&gt;                             &lt;ui:outputText value="{!wrap.art.Prix__c}" /&gt;                         &lt;/td&gt;                         &lt;td class="cell"&gt;                             &lt;button class="slds-button slds-button--neutral slds-not-selected"                                      onclick="{!c.getDetail}" data="{!wrap.art.Id}"&gt;Details&lt;/button&gt;                         &lt;/td&gt;                     &lt;/tr&gt;                 &lt;/aura:iteration&gt;             &lt;/tbody&gt;         &lt;/table&gt;   The associated controller js (with the function getDetail)  ({ doInit : function(component, event, helper) {     helper.init(component, event); },  getArticles : function(component, event, helper) {     helper.getArticles(component, event); },  getDetail : function(component, event, helper){     var id = event.target.getAttribute("data-data") || event.target.parentNode.getAttribute("data-data")     alert('detail article : id = ' + id); //it gives me null } })   Thanks !  EDIT  And the wrapper class in case you wonder what is the "art" :  public with sharing class ListeArticlesWrapper { //wrapper pour récupérer les articles selectionnés @AuraEnabled public Article__c art {get; set;}  @AuraEnabled public Boolean selected {get; set;} }
116439
I have a VF code below where I am trying to display the related list of an object using  and  command. I am rendering this page as PDF , doing that in my PDF I am unable to see the content in a tabular format. How can I make the content appear in a table?      &lt;apex:pageBlockSection columns="1" title="TECHNICAL ASSESSMENT"&gt;          &lt;apex:repeat value="{!interviewSkillReviews}" var="interview"&gt;              &lt;table border="1" cellpadding="6"&gt;                 &lt;apex:pageblockTable value="{!interview.Skill_review__r}" var="skillreview"&gt;                      &lt;apex:column headerValue="Skill Name"&gt;                                                         &lt;apex:outputText value="{!skillreview.Skill__r.Name}"/&gt;                     &lt;/apex:column&gt;                 &lt;apex:column headerValue="Recommended Level"&gt;                     &lt;apex:outputText value="{!skillreview.Level__r.Name}"/&gt;                 &lt;/apex:column&gt;                  &lt;apex:column headerValue="Rating"&gt;                     &lt;apex:outputField value="{!skillreview.RatingCopy__c}" rendered="{!NOT(interviewerMode)}" /&gt;                     &lt;apex:selectList value="{!rating}" multiselect="false" size="1" rendered="{!interviewerMode}"&gt;                         &lt;apex:selectOption itemValue="1" itemLabel="1"/&gt;                         &lt;apex:selectOption itemValue="2" itemLabel="2"/&gt;                         &lt;apex:selectOption itemValue="3" itemLabel="3"/&gt;                         &lt;apex:selectOption itemValue="4" itemLabel="4"/&gt;                         &lt;apex:selectOption itemValue="5" itemLabel="5"/&gt;                     &lt;/apex:selectList&gt;                 &lt;/apex:column&gt;                  &lt;apex:column headerValue="Rating Level Description"&gt;                     &lt;apex:outputText value="{!skillreview.Skill_Level_Description__c}"/&gt;                 &lt;/apex:column&gt;               &lt;/apex:pageblockTable&gt;         &lt;/table&gt;      &lt;/apex:repeat&gt; &lt;/apex:pageBlockSection&gt;   I tried using &lt;table&gt; command of HTML but I just get a border around the pageblocktable.    Example of table look and feel:
21618
I'm trying to add AJAX callback to form element that was previously rendered by AJAX but with no luck. Code below.   A bit of description. There are three main methods here:   buildForm - base form extraField - AJAX callback attached to ['month'] choosePerson - AJAX callback attached to: ['week_day']['hour']   In the buildForm method I create base form with AJAX callback on 'month' select element. In the AJAX callback you can find an extraField method. This method contains form element called 'hour' ($form['week_day']['hour']) and this element renders well. But this element also contains AJAX callback, which doesn't work, it does not generate 'person_container' element and the 'person' select.   Any idea how to ajaxify elements that previously were rendered by ajax?  class ReservationForm extends FormBase {    public function getFormId() {     return 'reservation_form';   }    public function buildForm(array $form, FormStateInterface $form_state) {      $form['month'] = array(       '#type' =&gt; 'select',       '#title' =&gt; $this-&gt;t('Select month'),       '#options' =&gt; array($this-&gt;t('January'), $this-&gt;t('February'), $this-&gt;t('March')),       '#ajax' =&gt; array(         'callback' =&gt; array($this, 'extraField'),         'event' =&gt; 'change',         'wrapper' =&gt; 'week-day',       ),     );      // Disable caching on this form.     $form_state-&gt;setCached(FALSE);      $form['week_day'] = [       '#type' =&gt; 'container',       '#attributes' =&gt; ['id' =&gt; 'week-day'],     ];   }    public function extraField(array &amp;$form, FormStateInterface $form_state) {     $month = $form_state-&gt;getValue('month');      $hour_options = array();      if ($month == '0') {       $hour_options[0] = $this-&gt;t('08:00');       $hour_options[1] = $this-&gt;t('09:00');       $hour_options[2] = $this-&gt;t('10:00');     }      if ($month == '1') {       $hour_options[0] = $this-&gt;t('12:00');       $hour_options[1] = $this-&gt;t('13:00');       $hour_options[2] = $this-&gt;t('14:00');     }      if ($month == '2') {       $hour_options[0] = $this-&gt;t('18:00');       $hour_options[1] = $this-&gt;t('19:00');       $hour_options[2] = $this-&gt;t('20:00');     }      $form['week_day']['hour'] = array(       '#type' =&gt; 'select',       '#title' =&gt; $this-&gt;t('Choose hours @month', array('@month' =&gt; $month)),       '#options' =&gt; $hour_options,       '#ajax' =&gt; array(         // tried with that callback too: [ $this, 'choosePerson']         'callback' =&gt; array($this, 'choosePerson'),         'event' =&gt; 'change',         'wrapper' =&gt; 'person',       ),     );      $form['week_day']['person_container'] = array(       '#type' =&gt; 'container',       '#attributes' =&gt; ['id' =&gt; 'person-container'],     );      $form['week_day']['person_container']['person'] = array(       '#type' =&gt; 'select',       '#title' =&gt; $this-&gt;t('Choose person'),       '#options' =&gt; ['John', 'Sarah', 'Peter'],     );      return $form['week_day'];   }    public function choosePerson(array &amp;$form, FormStateInterface $form_state) {     $form['week_day']['person_container']['person'] = array(       '#type' =&gt; 'select',       '#title' =&gt; $this-&gt;t('Choose person'),       '#options' =&gt; ['John', 'Sarah', 'Peter'],     );     return $form['week_day']['person_container'];   } }
20484
Recently I've been doing a lot of modal window pop-ups and what not, for which I used jQuery. The method that I used to create the new elements on the page has overwhelmingly been along the lines of:   $("&lt;div&gt;&lt;/div&gt;");   However, I'm getting the feeling that this isn't the best or the most efficient method of doing this. What is the best way to create elements in jQuery from a performance perspective?   has the benchmarks to the suggestions below.
39250
I have a form and I am using Drupal 7. I need to show this form in a popup when a user clicks a link. The user should then be able to complete the form whilst in the pop up window. I can use anything like  or modals or anything. I just wanted to know which is the better option and what options do I have for Drupal.
45710
I'm trying to test a page that has an input but really its a drop down list. The user enters text and then a dropdown appears based on what the user inputted. They are groups that are in the database. If I look for these elements before typing anything they dont exist but once I start typing they do exist.  The problem is I cant just type the whole name and then press enter or return because an option has to be selected from the list.  I can press arrow down to get the focus on the item from the list but then if I say enter it doesnt select, it sends that enter to the original element and nothing gets selected.  I can find the select element:  var ddList = driver.FindElement(By.CssSelector(".ui-autocomplete-input")); ddList.SendKeys("Admins");   This is the first time the list appears in the html.  It looks like this:  &lt;li class="ui-menu-item" role="presentation"&gt;
119241
Hi I'm new to LWC and I have worked on the data table where it's iterated one so its shows like multiple tables in real-time now in each table the user will pick only one option from the selection so I have used max-row-selection =1 but here the problem is how to deselect the rows in Programmatically in LWC? &lt;template for:each={oppList} for:item=&quot;table&quot;&gt;       &lt;div class=&quot;slds-m-bottom_large&quot; key={table.category}&gt;         &lt;!-- &lt;div class=&quot;table-header&quot;&gt;           &lt;h2&gt;{table.category}&lt;/h2&gt;          &lt;/div&gt; --&gt;         &lt;lightning-card key={table.category} icon-name=&quot;custom:custom11&quot;&gt;             &lt;h1 slot=&quot;title&quot;&gt;{table.category}&lt;/h1&gt;             &lt;/lightning-card&gt;         &lt;lightning-datatable           data-id={table.category}           key-field=&quot;Id&quot;           selected-rows={preSelectedRows}           onsave={handleSave}           onrowselection={handleRowSelection}           suppress-bottom-bar=&quot;true&quot;           max-row-selection=&quot;1&quot;           draft-values={draftValues}           data={table.data}           columns={column}                    &gt;         &lt;/lightning-datatable&gt;       &lt;/div&gt;             &lt;/template&gt;  and my js  handleRowSelection = event =&gt; {         var selectedRows=event.detail.selectedRows;         if(selectedRows.length&gt;1)         {             var el = this.template.querySelector('lightning-datatable');             selectedRows=el.selectedRows=el.selectedRows.slice(1);             event.preventDefault();             return;         }          }  attached my sample screenshot. [![enter image description here][1]][1] Thanks in Advance.
88341
I want to use a table in my answer. e.g  |-------------|----------------| | ShortCut    | Description    | |-------------|----------------|  I have posted an answer , which requires this kind of formatting.   Is it possible to have such formatting in stackoverflow Questions &amp; answers ?    If yes, How ? If no, why ?   Edit : I tried to use following code directly in editor of SO. But it didn't work for me.  &lt;table&gt; &lt;tr&gt; &lt;td&gt;hello&lt;/td&gt; &lt;td&gt;hello2&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;hello3&lt;/td&gt; &lt;td&gt;hello4&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;
80897
I'm trying to find a way with javascript to highlight the text the user selects when they click some odd highlight button (as in &lt;span style="background-color:yellow"&gt;highlighted text&lt;/span&gt;). It only has to work with either WebKit or Firefox, but it seems to be well nigh impossible because it has to work in the following cases:  &lt;p&gt;this is text&lt;/p&gt; &lt;p&gt;I eat food&lt;/p&gt;   When the user selects from "is text" through "I eat" in the browser (can't just put a span there).  and this case:  &lt;span&gt;&lt;span&gt;this is text&lt;/span&gt;middle text&lt;span&gt;this is text&lt;/span&gt;&lt;/span&gt;   When the user selects from "is text" to "this is" in the browser (even though you can wrap your highlight spans around each element in the selection, I'd like to see you try to get that middle text highlighted).  This problem doesn't seem to be solved anywhere, frankly I doubt it's possible.  It would be possible if you could get the Range that you get from the selection as a string complete with html which could be parsed and then replaced, but as far as I can tell you can't get the raw html of a Range.. pity.
6732
I have a custom search page for use in Customer Portal.  VF Page:    &lt;form name="frmSearch"&gt;      &lt;input type="text" name="keyword" id="keyword" value="{!portalSearchModel.searchTerm}" onkeypress="return noenter(event);" style="width:25%; height:25px;margin:0; padding: 0px 6px 0px;" placeholder="What are you looking for?" /&gt;      &lt;input type="button" id="btnSearch" name="btnSearch" value="Search" onclick="searchTerm()" class="go-we3" /&gt;   &lt;/form&gt;   &lt;script type='text/javascript'&gt;       function searchTerm(){         var searchTerm = document.getElementById("keyword").value;          var url="/apex/PortalSearch?s="+searchTerm;          window.location = url;          return false;     }          &lt;/script&gt;   Is there a way to call this apex method in Controller on button click along with the JavaScript?      public void logSearchTerm(){         portalSearchModel.searches();         Search_Log__c sl = new Search_Log__c();          sl.search_term__c = portalSearchModel.searchTerm;         sl.user__c = UserInfo.getUserId();              insert sl;  }
16373
How do I pass have a Javascript script request a PHP page and pass data to it? How do I then have the PHP script pass data back to the Javascript script?  client.js:  data = {tohex: 4919, sum: [1, 3, 5]}; // how would this script pass data to server.php and access the response?   server.php:  $tohex = ... ; // How would this be set to data.tohex? $sum = ...; // How would this be set to data.sum? // How would this be sent to client.js? array(base_convert($tohex, 16), array_sum($sum))
16554
When I create a form using the form API, the resulting html includes all sorts of unwanted divs. For example, if I use:  $form = array(     'myFieldset' =&gt; array(         '#type' =&gt; 'fieldset'     ) );   The resulting html looks like this:   &lt;form action="/drupal-7.15/?q=chercheur" method="post" id="form-chercheur" accept-charset="UTF-8"&gt;     &lt;div&gt;         &lt;fieldset class="form-wrapper" id="edit-myfieldset"&gt;             &lt;div class="fieldset-wrapper"&gt;             &lt;/div&gt;         &lt;/fieldset&gt;         &lt;input type="hidden" name="form_build_id" value="form-87Dv5ezVpaLI5mD345ofMkLgPhsv_dawudUp73ePQTc" /&gt;         &lt;input type="hidden" name="form_token" value="sXXINWr7rmParm0tRJoEb6QKGIH_QH-ffRSOtnvxYY0" /&gt;         &lt;input type="hidden" name="form_id" value="form_Chercheur" /&gt;     &lt;/div&gt; &lt;/form&gt;   As you can see, two extraneous divs are added here. They are making the javascript I'm writing uselessly complicated, so I was wondering if there was a way to remove the extraneous divs. Ideally, I would like to obtain something like this:  &lt;form action="/drupal-7.15/?q=chercheur" method="post" id="form-chercheur" accept-charset="UTF-8"&gt;     &lt;fieldset class="form-wrapper" id="edit-myfieldset"&gt;     &lt;/fieldset&gt;     &lt;input type="hidden" name="form_build_id" value="form-87Dv5ezVpaLI5mD345ofMkLgPhsv_dawudUp73ePQTc" /&gt;     &lt;input type="hidden" name="form_token" value="sXXINWr7rmParm0tRJoEb6QKGIH_QH-ffRSOtnvxYY0" /&gt;     &lt;input type="hidden" name="form_id" value="form_Chercheur" /&gt; &lt;/form&gt;   Is this possible?
92236
I have an xml file which I would like to create a form/table around to add, edit and delete records using PHP.  Currently I use simpleXML to load the XML file, and display its content on various pages.  Is there any way I can create a table that shows all results, and allows me to either edit or delete that particular row of the table which represents a full record within the XML file.    When clicking edit I would like the details from the record to appear in a form which the user can change and then save out, updating the XML file and the corresponding web page.  I need this done in PHP, preferably using SimpleXML, though open to suggestions of other ways to do this with PHP.  Cheers
82255
I'm making a page which has some interaction provided by javascript. Just as an example: links which send an AJAX request to get the content of articles and then display that data in a div. Obviously in this example, I need each link to store an extra bit of information: the id of the article. The way I've been handling it in case was to put that information in the href link this:  &lt;a class="article" href="#5"&gt;   I then use jQuery to find the a.article elements and attach the appropriate event handler. (don't get too hung up on the usability or semantics here, it's just an example)  Anyway, this method works, but it  a bit, and isn't extensible at all (what happens if the click function has more than one parameter? what if some of those parameters are optional?)  The immediately obvious answer was to use attributes on the element. I mean, that's what they're for, right? (Kind of).  &lt;a articleid="5" href="link/for/non-js-users.html"&gt;   In  I asked if this method was valid, and it turns out that short of defining my own DTD (I don't), then no, it's not valid or reliable. A common response was to put the data into the class attribute (though that might have been because of my poorly-chosen example), but to me, this smells even more. Yes it's technically valid, but it's not a great solution.  Another method I'd used in the past was to actually generate some JS and insert it into the page in a &lt;script&gt; tag, creating a struct which would associate with the object.  var myData = {     link0 : {         articleId : 5,         target : '#showMessage'         // etc...     },     link1 : {         articleId : 13     } };  &lt;a href="..." id="link0"&gt;   But this can be a real pain in butt to maintain and is generally just very messy.  So, to get to the question, how do you store arbitrary pieces of information for HTML tags?