Search Results

Search found 53 results on 3 pages for 'selectbox'.

Page 1/3 | 1 2 3  | Next Page >

  • Apply jquery selectbox style on chained selectbox

    - by ktsixit
    Hi all, I have created a pair of chained selectboxes in my page. The second selectbox is filled with a set of values, depending on the first box's selected value. The script that makes the two selectboxes work like this, uses php and javascript. This is the code I'm using: form <select name="continent" tabindex="1" onChange="getCountry(this.value)"> <option value="#">-Select-</option> <option value="Europe">Europe</option> <option value="Asia">Asia</option> </select> <div id="countrydiv"> <select name="country" tabindex="2"> <option></option> </select> </div> <input type="submit" /> </form> javascript code $(document).ready(function() { $('select[name="continent"]').selectbox({debug: true}); $('select[name="country"]').selectbox({debug: true}); }); function getXMLHTTP() { //fuction to return the xml http object var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getCountry(continentId) { var strURL="findCountry.php?continent="+continentId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('countrydiv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } php code (findCountry.php) <? $continent=intval($_GET['continent']); if ($_GET['continent'] == 'Europe') { ?> <select name="country"> <option value="France">France</option> <option value="Germany">Germany</option> <option value="Spain">Spain</option> <option value="Italy">Italy</option> </select> <? } if ($_GET['continent'] == 'Asia') { ?> <select name="country"> <option value="China">China</option> <option value="India">India</option> <option value="Japan">Japan</option> </select> <? } ?> What I want to do is to apply jquery selectbox styling on these selectboxes. I haven't succeeded in doing that yet. The problem is that jquery is hiding the normal selectbox and is replacing it with a list. Furthermore, after selectbox's content is refreshed, jquery cannot re-construct it into a list. You can take a look of the jquery code here Is there something I can do to combine these techniques? I have tried a million things but nothing worked. Can you please help me?

    Read the article

  • move selected item from one selectbox to another selectbox(with duplicate prevention)

    - by I Like PHP
    i have two select box, now what i want is i want to move option from one select box to another via a button below is my code: php <table> <tr> <td> <select size="5" id="suppliedMovies" name="suppliedMovies"> <option selected="selected" value="">Select Movie</option> <option value="1">sholay</option> <option value="3">Jism</option> <option value="4">Rog</option> <option value="5">Zeher</option> <option value="6">Awarpan</option> <option value="7">Paap</option> <option value="8">paanch<option> <option value="9">no entry</option> </select> </td> <td> <input type="button" id="toRight" value="&gt;&gt;"><br> <input type="button" id="toLeft" value="&lt;&lt;"> </td> <td> <select size="5" id="accquiredMovies" name="accquiredMovies"> <option> No item right now</option> </select> </td> </tr> </table> Jquery jQuery(document).ready( function() { function displayVals() { var myValues = jQuery("#suppliedMovies").val(); return myValues; } jQuery('#toRight').click(function(){ var x=displayVals(); console.log(x); var txt=jQuery("#suppliedMovies option[value='"+x+"']").text(); console.log(txt); if(x!=''){ jQuery('#accquiredMovies').append("<option value='"+x+"' >"+txt+"</option>"); } }); }); i m using above jQuery, that is working fine but, i want that when one item is copy from one select box to another select box, then that item should be disable(or probably delete) from first select box (to prevent duplicate entry). i also want to move item from right to left select box please suggest me optimized jQuery . Thanks. UPDATE if i want to use multiple select box on both side? then how do i use that? more update if i click on a item on rightselectbox and move it to left selectbox, and go further(post) then on right selectbox, there is nothing selected items?? what i need is on right selectbox, there all items shoud be always selected , otherwise what i need to do? after i move an item from right to left ,i again have to select rest of items on right selectbox and go further

    Read the article

  • is there any chance of sql injection through selectbox( dynamically created or static)

    - by I Like PHP
    Hello All, i want to know that is there any chance of SQL injection via selectbox options? if yes then will u please show some demonstration(or refer any link). and also tell me how do we prevent sql injection in selectbox.(using PHP MYSQL) one more: if i create a selectbox dynamically( based on options of another select box) then is there any chance of SQLinjection? Thanking you.

    Read the article

  • Create a multicolor selectbox on Symfony2

    - by Ninsuo
    I try to create the following field : <select name="test"> <option value="1">a</option> <option value="2">b</option> <option value="3" style="font-weight: bold; color: red;">c</option> <option value="4">d</option> <option value="5">e</option> </select> This creates a 2-color selectbox : But in Symfony2, I do not know how to apply a class to a single option. If in my view I do : {{ form_widget(myForm.test, { 'attr': { 'class': 'red', } }) }} Or if in my form I do : $builder->add('test', 'choice', array( 'required' => true, 'choices' => array('a', 'b', 'c', 'd', 'e'), 'attr' => array('class' => 'red'), )); The attribute is stored into the <select> tag and apply to the whole selectable values. How do I apply a class to an <option> in Symfony2 ?

    Read the article

  • Need Magic jQuery Replacement for Selectbox Dropdown Form Element. Thank you!

    - by PlasmaFlux
    Hello! I'm stuck on a problem and, after what seems like days of searching for a solution, I'm reaching out to Stack Overflow for help. I'm trying to replace a standard dropdown form element with a Textbox and a Div containing an unordered list. I'd prefer to have the solution be based on jQuery, but am open to alternatives. I've found a couple jQuery plugins that -almost- do what I need, but are far enough from being a real solution that I need to keep looking. Here's an image of what I'm going for: I'd like the dropdown to look as pictured, and when an element is selected (with mouse or keyboard), have just the first line handed back into the textbox (and not be editable). I'd also like to populate a hidden input field with a value that will be used on Submit. I'm pulling my hair out over this one. Any help and guidance will be most appreciated! Thanks! ~PF

    Read the article

  • Problem with JS Selectbox Function

    - by Thomas
    I have a selectbox with three options. When a user selects one of the three options, I want a specific div to appear below it. I am trying to write the code that dictates which specific box is to appear when each of the three options is selected. So far, I have only worked on the code that pertains to the first option. However, whenever the user selects any of the three options from the selectbox, the function for the first option is triggered and the div is displayed. My question is two part: 1) How do I write a conditional function that specifically targets the selected option 2) What is the best way to accomplish what I have described above; How do I efficiently go about defining three different functions for three different options in a select box? Here is the function I was working on for the first option: $(document).ready(function(){ var subTableDiv = $("div.subTableDiv"); var subTableDiv1 = $("div.subTableDiv1"); var subTableDiv2 = $("div.subTableDiv2"); subTableDiv.hide(); subTableDiv1.hide(); subTableDiv2.hide(); var selectmenu=document.getElementById("customfields-s-18-s"); selectmenu.onchange=function(){ //run some code when "onchange" event fires var chosenoption=this.options[this.selectedIndex].value //this refers to "selectmenu" if (chosenoption.value ="Co-Op"){ subTableDiv1.slideDown("medium"); } } }); Html: <tr> <div> <select name="customfields-s-18-s" class="dropdown" id="customfields-s-18-s" > <option value="Condominium"> Condominium</option> <option value="Co-Op"> Co-Op</option> <option value="Condop"> Condop</option> </select> </div> </tr> <tr class="subTable"> <td colspan="2"> <div style="background-color: #EEEEEE; border: 1px solid #CCCCCC; padding: 10px;" id="Condominium" class="subTableDiv">Hi There! This is the first Box</div> </td> </tr> <tr class="subTable"> <td colspan="2"> <div style="background-color: #EEEEEE; border: 1px solid #CCCCCC; padding: 10px;" id="Co-Op" class="subTableDiv1">Hi There! This is the Second Box</div> </td> </tr> <tr class="subTable"> <td colspan="2"> <div style="background-color: #EEEEEE; border: 1px solid #CCCCCC; padding: 10px;" id="Condop" class="subTableDiv2">Hi There! This is the Third Box.</div> </td> </tr>

    Read the article

  • Safari extensions: style of selectbox like safari's bookmark folders

    - by janoliver
    Hey guys, I'm developing an extension for Safari 5 at the moment. In my extension, I use an additional toolbar, with selectboxes in it. Now, it would be great to style these like the folders in the bookmarks toolbar look. I know that it would be possible to replace my select with a completely styleable ul-list or somethin like that, but maybe there is a simpler solution. Doesn't apple provide extra tools to imitate their look? Best regards and thanks for help, Jan

    Read the article

  • django admin how to limit selectbox values

    - by SledgehammerPL
    model: class Store(models.Model): name = models.CharField(max_length = 20) class Admin: pass def __unicode__(self): return self.name class Stock(Store): products = models.ManyToManyField(Product) class Admin: pass def __unicode__(self): return self.name class Product(models.Model): name = models.CharField(max_length = 128, unique = True) parent = models.ForeignKey('self', null = True, blank = True, related_name='children') (...) def __unicode__(self): return self.name mptt.register(Product, order_insertion_by = ['name']) admin.py: from bar.drinkstore.models import Store, Stock from django.contrib import admin admin.site.register(Store) admin.site.register(Stock) Now when I look at admin site I can select any product from the list. But I'd like to have a limited choice - only leaves. In mptt class there's function: is_leaf_node() -- returns True if the model instance is a leaf node (it has no children), False otherwise. But I have no idea how to connect it I'm trying to make a subclass: in admin.py: from bar.drinkstore.models import Store, Stock from django.contrib import admin admin.site.register(Store) class StockAdmin(admin.ModelAdmin): def queryset(self, request): qs = super(StockAdmin, self).queryset(request).filter(ihavenoideawhatfilter) admin.site.register(Stock, StockAdmin) but I'm not sure if it's right way, and what filter set.

    Read the article

  • Jquery / PhP / Joomla Select one of two comboboxes does not get updated

    - by bluesbrother
    I am making a Joomla component wich has 3 comboboxes/selects on the page. One with languages and 2 with subjects. If you change the language the other two get filled with the same data (the subjects in the selected language) the name of the selectbox are different but otherwise the same. I get an error for one of the subject boxes (hence the url gets red), but there is no logic in wich one will give an error. In Firebug i get the HTML back for the one without the other and this one gets updated but the other one gives nothing back. If i right click in firebug on the one that gave the error, and do "send again" it will load fine. Is their a timing problem? The change event of the language selectbox: jQuery('#cmbldcoi_ldlink_language').bind('change', function() { var cmbLangID = jQuery('#cmbldcoi_ldlink_language').val(); if (cmbLangID !=0) { getSubjectCmb_lang(cmbLangID, 'cmbldcoi_ldlink_subjects', '#ldlinksubjects'); } }); Function that requests the php file to create the html for the select: function getSubjectCmb_lang(langID, cmbName, DivWhereIn) { var xdate = new Date().getTime(); var url = 'index.php?option=com_ldadmin&view=ldadmin&format=raw&task=getcmbsubj_lang&langid=' + langID + '&cmbname=' + cmbName + '&'+ xdate; jQuery(DivWhereIn).load(url, function(){ }); } And in the php file there is a connection made to the database to ge the information to build the selectbox. I use a function for this that is okay because it makes al my selectboxes. The only place where there are problems with select boxes is on the pages that has 2 selects that need to change when a third one changed. My guess it is somewhere in the Jquery where this goes wrong. And i think it has to do with timing. But i am open for all sugestions. Thanx. UPDATE: No the ID and Name fields are different. They are named : cmbldcoi_child cmbldcoi_parent Here is my code: The change event for the first combobox which makes the other two change: jQuery('#cmbldcoi_language_chain_subj').bind('change', function(){ var langID = jQuery('#cmbldcoi_language_chain_subj').val(); if (langID != 0){ getSubjectCmb_lang(langID, 'cmbldcoi_child', '#div_cmbldcoi_child'); getSubjectCmb_lang(langID, 'cmbldcoi_parent', '#div_cmbldcoi_parent'); } }); } The function wicht calls the php file to get the info from the database: function getSubjectCmb_lang(langID, cmbName, DivWhereIn){ var xdate = new Date().getTime(); var url = 'index.php?option=com_ldadmin&view=ldadmin&format=raw&task=getcmbsubj_lang&langid=' + langID + '&cmbname=' + cmbName + '&'+ xdate; jQuery(DivWhereIn).load(url, function(){ }); } The PHP code function getcmbsubj_lang(){ $langid = JRequest::getVar('langid'); if ($langid > 0 ){ $langid = JRequest::getVar('langid'); }else{ $langid = 1; } $cmbName = JRequest::getVar('cmbname'); //$lang_sufx = self::get_#__sufx($langid); print ld_html::ld_create_cmb_html($cmbName, '#__ldcoi_subjects','id', 'subject_name', " WHERE id_language={$langid} ORDER BY subject_name" ); } There is a class wich is called ld_html wich has an funnction in it that creates a combobox. ld_html::ld_create_cmb_html() It gets an table name, id field, namefield and optional an where clause. It all works fine if there is just one combobox thats needs updating. It give a problem when there are two. Thanks for the help !

    Read the article

  • javascript select box hanging on second select in ie7

    - by bsandrabr
    I have a drop down select box inside a div. When the user clicks on change, a dropdown box appears next to the change/submit button and the user makes a selection which then updates the db and the selection appears instead of the dropdown. All works fine in IE8 and firefox but in IE7 it allows one selection (there are several identical dropdowns) but the second time a selection is made it hangs on please wait. This is the relevant code <td width=200> <input type="button" onclick="startChanging(this)" value="Change" /></td> <script type="text/javascript"> var selectBox, isEditing = false; var recordvalue; if( window.XMLHttpRequest ) { recordvalue = new XMLHttpRequest(); } else if( window.ActiveXObject ) { try { recordvalue = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {} } window.onload = function () { selectBox = document.getElementById('changer'); selectBox.id = ''; selectBox.parentNode.removeChild(selectBox); }; function startChanging(whatButton) { if( isEditing && isEditing != whatButton ) { return; } //no editing of other entries if( isEditing == whatButton ) { changeSelect(whatButton); return; } //this time, act as "submit" isEditing = whatButton; whatButton.value = 'Submit'; var theRow = whatButton.parentNode.parentNode; var stateCell = theRow.cells[3]; //the cell that says "present" stateCell.className = 'editing'; //so you can use CSS to remove the background colour stateCell.replaceChild(selectBox,stateCell.firstChild); //PRESENT is replaced with the select input selectBox.selectedIndex = 0; } function changeSelect(whatButton) { isEditing = true; //don't allow it to be clicked until submission is complete whatButton.value = 'Change'; var stateCell = selectBox.parentNode; var theRow = stateCell.parentNode; var editid = theRow.cells[0].firstChild.firstChild.nodeValue; //text inside the first cell var value = selectBox.firstChild.options[selectBox.firstChild.selectedIndex].value; //the option they chose selectBox.parentNode.replaceChild(document.createTextNode('Please wait...'),selectBox); if( !recordvalue ) { //allow fallback to basic HTTP location.href = 'getupdate.php?id='+editid+'&newvalue='+value; } else { recordvalue.onreadystatechange = function () { if( recordvalue.readyState != 4 ) { return; } if( recordvalue.status >= 300 ) { alert('An error occurred when trying to update'); } isEditing = false; newState = recordvalue.responseText.split("|"); stateCell.className = newState[0]; stateCell.firstChild.nodeValue = newState[1] || 'Server response was not correct'; }; recordvalue.open('GET', "getupdate.php?id="+editid+"&newvalue="+value, true); recordvalue.send(null); } } </script> If anyone has any idea why this is happening I'd be very grateful

    Read the article

  • Apply jump menu functionality on select box styled with jquery

    - by ktsixit
    Hi all, I am using this script to apply style on a select box. It works fine as a standalone version. But I also need to apply a jump menu functionality on this select box. I tried adding a function but it seems that there is some conflict between the two scripts. The jquery styling and the jump menu function can't work together at the same time. Can you help me fix it? This is a sample code to let you know what I'm dealing with here: <script type="text/javascript"> $(document).ready(function() { $('#jumpMenu').selectbox({debug: true}); function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } }); </script> <select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)"> <option value="http://www.link1.com">link1</option> <option value="http://www.link2.com">link2</option> <option value="http://www.link3.com">link3</option> </select>

    Read the article

  • The width of items in select box is different in IE 8, Firefox and Google Chrome

    - by Purushotham
    I have a problem with the select box in my application. I specified some width to the select box. The width of some of the items in the select box is more than the actual width of the select box. Each browser is treating it differently. I can see a shrink of the select box items in IE 8. Whereas google chrome and firefox takes the maximum width of the items in the select box. I want to control the width of the select box. Is there any way to do this ?

    Read the article

  • Cufon text z-index (IE6 and IE7 stylish select box bug)

    - by Adrian
    Hello, I'm replacing some text with cufon on my page and I'm using jquery stylish select box plugin (http://www.scottdarby.com/plugins/stylish-select/0.4/) to style select boxes. The problem is that, in IE6 and IE7, select box goes under the cufonized text. (the select box is actually an <ul>). Anyone had this issue before? Thanks, Adrian

    Read the article

  • Select box is not working properly after including google custom search box in web page

    - by Vinay
    I have got a select box and google custom search box in a page, when i choose a option from select box and navigate away from the page and again if i come back to the same page the option will not be selected (violates the default functionality of select box), The code is below <script src="https://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript"> google.load('search', '1', {language : 'en'}); google.setOnLoadCallback(function() { var customSearchControl = new google.search.CustomSearchControl('004920913350056953771:kpkclvhujzk'); customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); var options = new google.search.DrawOptions(); options.setAutoComplete(true); options.enableSearchboxOnly("<?=$homeurl?>my_results.php", "query"); customSearchControl.draw('cse-search-form', options); }, true); </script> <select multiple="yes"> <option>1</option> <option>2</option> </select> If i remove the custom search script, the select box selected option will be retained even after navigating away from the page. (default functionality) Its working fine in chrome, IE but not in Firefox. Is there any solution for this, so that select box must work fine even in the presence of search box, but the order must be same 1) Search box 2)Select Box

    Read the article

  • How do I make a grouped select box grouped by a column for a given model in Formtastic for Rails?

    - by jklina
    In my Rails project I'm using Formtastic to manage my forms. I have a model, Tags, with a column, "group". The group column is just a simple hardcoded way to organize my tags. I will post my Tag model class so you can see how it's organized class Tag < ActiveRecord::Base class Group BRAND = 1 SEASON = 2 OCCASION = 3 CONDITION = 4 SUBCATEGORY = 5 end has_many :taggings, :dependent => :destroy has_many :plaggs, :through => :taggings has_many :monitorings, :as => :monitorizable validates_presence_of :name, :group validates_uniqueness_of :name, :case_sensitive => false def self.brands(options = {}) self.all({ :conditions => { :group => Group::BRAND } }.merge(options)) end def self.seasons(options = {}) self.all({ :conditions => { :group => Group::SEASON } }.merge(options)) end def self.occasions(options = {}) self.all({ :conditions => { :group => Group::OCCASION } }.merge(options)) end def self.conditions(options = {}) self.all({ :conditions => { :group => Group::CONDITION } }.merge(options)) end def self.subcategories(options = {}) self.all({ :conditions => { :group => Group::SUBCATEGORY } }.merge(options)) end def self.non_brands(options = {}) self.all({ :conditions => [ "`group` != ? AND `group` != ?", Tag::Group::SUBCATEGORY, Tag::Group::BRAND] }.merge(options)) end end My goal is to use Formtastic to provide a grouped multiselect box, grouped by the column, "group" with the tags that are returned from the non_brands method. I have tried the following: = f.input :tags, :required => false, :as => :select, :input_html => { :multiple => true }, :collection => tags, :selected => sel_tags, :group_by => :group, :prompt => false But I receive the following error: (undefined method `klass' for nil:NilClass) Any ideas where I'm going wrong? Thanks for looking :]

    Read the article

  • jQuery HOW TO?? pass additional parameters to success callback for $.ajax call ?

    - by dotnetgeek
    Hello jQuery Ninjas! I am trying, in vain it seems, to be able to pass additional parameters back to the success callback method that I have created for a successful ajax call. A little background. I have a page with a number of dynamically created textbox / selectbox pairs. Each pair having a dynamically assigned unique name such as name="unique-pair-1_txt-url" and name="unique-pair-1_selectBox" then the second pair has the same but the prefix is different. In an effort to reuse code, I have crafted the callback to take the data and a reference to the selectbox. However when the callback is fired the reference to the selectbox comes back as 'undefined'. I read here that it should be doable. I have even tried taking advantage of the 'context' option but still nothing. Here is the script block that I am trying to use: <script type="text/javascript" language="javascript"> $j = jQuery.noConflict(); function getImages(urlValue, selectBox) { $j.ajax({ type: "GET", url: $j(urlValue).val(), dataType: "jsonp", context: selectBox, success:function(data){ loadImagesInSelect(data, $j(this)) } , error:function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); } }); } function loadImagesInSelect(data, selectBox) { //var select = $j('[name=single_input.<?cs var:op_unique_name ?>.selImageList]'); var select = selectBox; select.empty(); $j(data).each(function() { var theValue = $j(this)[0]["@value"]; var theId = $j(this)[0]["@name"]; select.append("<option value='" + theId + "'>" + theValue + "</option>"); }); select.children(":first").attr("selected", true); } From what I have read, I feel I am close but I just cant put my finger on the missing link. Please help in your typical ninja stealthy ways. TIA

    Read the article

  • Javascript Selectbox refresh necessary in YUI 3, when selecting none?

    - by Jasie
    Hi all, I'm using YUI 3 to let someone click "Select All" or "Select None" and then have the selectbox select all the items or unselect all of them, respectively. Here's my code: // This selects all Y.on('click',function (e) { selectBoxNode.get("options").each(function () { this.removeAttribute('selected'); this.setAttribute('selected','selected'); }); }, selectAllNode ); // This selects none Y.on('click',function (e) { selectBoxNode.get("options").each(function () { this.setAttribute('selected','false'); this.removeAttribute('selected'); }); selectBoxNode.('selectedIndex',-1); }, selectNoneNode ); selectAllLink, selectNoneLink, and selectBoxNode are self-evident, properly returned Nodes. Update: selectAll works, I had to manually remove the 'selected' attribute for each and re-add it. The selectNoneLink doesn't work: it unselects only the elements that weren't before selected... although DOM inspection shows that the selectedIndex attribute is indeed changed to -1, so maybe it needs a refresh? Any help would be appreciated. If this happens in all frameworks, that would be nice to know as well. Thanks!

    Read the article

  • How can I organize many results in a selectbox using php?

    - by zeckdude
    I have a select box that is part of a form. It is currently querying the addresses table and displaying the addresses into the select box. I plan on having up to 100 addresses. I'm looking for a solution where I can show all the states if the user clicks on the select box. Then if the user hovers over a state it will show all the addresses for that specific state. Then if the user clicks on an address, it will show that as the picked option in the select box. This is like a dropdown menu within a select box. Does anyone know where I can find a solution as this?

    Read the article

  • How can I organize many results in a selectbox?

    - by zeckdude
    I have a select box that is part of a form. It is currently querying the addresses table and displaying the addresses into the select box. I plan on having up to 100 addresses. I'm looking for a solution where I can show all the states if the user clicks on the select box. Then if the user hovers over a state it will show all the addresses for that specific state. Then if the user clicks on an address, it will show that as the picked option in the select box. This is like a dropdown menu within a select box. Does anyone know where I can find a solution as this?

    Read the article

  • Add options to select box without Internet Explorer closing the box?

    - by Paul Colby
    Hi, I'm trying to build a web page with a number of drop-down select boxes that load their options asynchronously when the box is first opened. This works very well under Firefox, but not under Internet Explorer. Below is a small example of what I'm trying to achieve. Basically, there is a select box (with the id "selectBox"), which contains just one option ("Any"). Then there is an onmousedown handler that loads the other options when the box is clicked. <html> <head> <script type="text/javascript"> function appendOption(select,option) { try { selectBox.add(option,null); // Standards compliant. } catch (e) { selectBox.add(option); // IE only version. } } function loadOptions() { // Simulate an AJAX request that will call the // loadOptionsCallback function after 500ms. setTimeout(loadOptionsCallback,500); } function loadOptionsCallback() { var selectBox = document.getElementById('selectBox'); var option = document.createElement('option'); option.text = 'new option'; appendOption(selectBox,option); } </script> </head> <body> <select id="selectBox" onmousedown="loadOptions();"> <option>Any</option> </select> </body> </html> The desired behavior (which Firefox does) is: the user see's a closed select box containing "Any". the user clicks on the select box. the select box opens to reveal the one and only option ("Any"). 500ms later (or when the AJAX call has returned) the dropped-down list expands to include the new options (hard coded to 'new option' in this example). So that's exactly what Firefox does, which is great. However, in Internet Explorer, as soon as the new option is added in "4" the browser closes the select box. The select box does contain the correct options, but the box is closed, requiring the user to click to re-open it. So, does anyone have any suggestions for how I can load the select control's options asynchronously without IE closing the drop-down box? I know that I can load the list before the box is even clicked, but the real form I'm developing contains many such select boxes, which are all interrelated, so it will be much better for both the client and server if I can load each set of options only when needed. Also, if the results are loaded synchronously, before the select box's onmousedown handler completes, then IE will show the full list as expected - however, synchronous loading is a bad idea here, since it will completely "lock" the browser while the network requests are taking place. Finally, I've also tried using IE's click() method to open the select box once the new options have been added, but that does not re-open the select box. Any ideas or suggestions would be really appreciated!! :) Thanks! Paul.

    Read the article

  • jQuery SlideDown Flickering in Firefox

    - by Sithlord
    Hi, once more a jQuery, Firefox flickering issue. (no flickering in IE6/7/8, Safari) I uploaded an example page here: http://sithlord.bplaced.net/testing/jquery_flickering/flickering.html There are two div containers. The inner div is the one I'm hiding. The outer one is the wraping container with the style elements. I found the flicker only occur with the selectbox. Without the SelectBox there is no flickering. But thats not all: (I cant post a second hyperlink: its the same link as above; only change "flickering.html" to not_flickering.html) In this case I selected a lower "option" - as you can see, the flicker disappears in this case. The same is happending, when there are less options in total. (less then about 20) The only workaround I found is deleting the selectbox :) Any ideas, why this is happening and how to fix it? Thanks!

    Read the article

  • Having a problem displaying data from last inserted data

    - by Gideon
    I'm designing a staff rota planner....have three tables Staff (Staff details), Event (Event details), and Job (JobId, JobDate, EventId (fk), StaffId (fk)). I need to display the last inserted job detail with the staff name. I've been at it for couple of hours and getting nowhere. Thanks for the help in advance. My code is the following: $eventId = $_POST['eventid']; $selectBox = $_POST['selectbox']; $timePeriod = $_POST['time']; $selectedDate = $_POST['date']; $count = count($selectBox); //constructing the staff selection if (empty($selectBox)) { echo "<p>You didn't select any member of staff to be assigned."; echo "<p><input type='button' value='Go Back' onClick='history.go(-1)'>"; } else { echo "<p> You selected ".$count. " staff for this show."; for ($i=0;$i<$count;$i++) { $selectId = $selectBox[$i]; //insert the details into the Job table in the database $insertJob = "INSERT INTO Job (JobDate, TimePeriod, EventId, StaffId) VALUES ('".$selectedDate."', '".$timePeriod."', ".$eventId.", ".$selectId.")"; $exeinsertJob = mysql_query($insertJob) or die (mysql_error()); } } //display the inserted job details $insertedlist = "SELECT Job.JobId, Staff.LastName, Staff.FirstName, Job.JobDate, Job.TimePeriod FROM Staff, Job WHERE Job.StaffId = Staff.StaffId AND Job.EventId = $eventId AND Job.JobDate = ".$selectedDate; $exeinsertlist = mysql_query($insertedlist) or die (mysql_error()); if ($exeinsertlist) { echo "<p><table cellspacing='1' cellpadding='3'>"; echo "<tr><th colspan=5> ".$eventname."</th></tr>"; echo "<tr><th>Job Id</th><th>Last Name</th> <th>First Name </th><th>Date</th><th>Hours</th></tr>"; while ($joblistarray = mysql_fetch_array($exeinsertlist)) { echo "<tr><td align=center>".$joblistarray['JobId']." </td><td align=center>".$joblistarray['LastName']."</td><td align=center>".$joblistarray['FirstName']." </td><td align=center>".$joblistarray['JobDate']." </td><td align=center>".$joblistarray['TimePeriod']."</td></tr>"; } echo "</table>"; echo "<h3><a href=AssignStaff.php>Add More Staff?</a></h3>"; } else { echo "The Job list can not be displayed at this time. Try again."; echo "<p><input type='button' value='Go Back' onClick='history.go(-1)'>"; }

    Read the article

  • load Javascript object from file

    - by megapool020
    Hi there, I asked a question in this thread Stackoverflow, and it works perfect. So tnx to all the users who gave me a reply. But now I have a other question. I would like to have the object in a seperate file, so I only need to update the file in stead of the JS file (otherwise it will be very big). I'm using JQUERY. I now looks like this (with all the info in the JS file). IBANInfo is used to fill a selectbox var IBANInfo = { "ccAL":{ countryCode:"AL", countryName:"Albani&euml;", IBANlength:"28", bankFormCode:"0 8n 0 ", accountNum:"0 16 0 " }, "ccAD":{ countryCode:"AD", countryName:"Andorra", IBANlength:"24", bankFormCode:"0 4n 4n", accountNum:"0 12 0 " }, "ccBE":{ countryCode:"BE", countryName:"Belgi&euml;", IBANlength:"16", bankFormCode:"0 3n 0 ", accountNum:"0 7n 2n" } }; //---- then this function is used to build the selectList function createSelect(){ var selectList = ''; var key; selectList += "<option value=''>Kies een land</option>\n"; for (key in IBANInfo) { if (IBANInfo.hasOwnProperty(key)) { var countryInfo = IBANInfo[key]; selectList += "<option value='"+countryInfo.countryCode+"'>"+countryInfo.countryName+"</option>\n"; } } $('#selectBox').html(selectList); } I thought I could do it like this, but I get the message undefined in my selectbox. var IBANInfo = $.get('include/countryCodes.txt'); // also tried var IBANInfo = $.getJSON('include/countryCodes.txt'); //---- then this function is used to build the selectList function createSelect(){ var selectList = ''; var key; selectList += "<option value=''>Kies een land</option>\n"; for (key in IBANInfo) { if (IBANInfo.hasOwnProperty(key)) { var countryInfo = IBANInfo[key]; selectList += "<option value='"+countryInfo.countryCode+"'>"+countryInfo.countryName+"</option>\n"; } } $('#selectBox').html(selectList); } /* the countryCodes.txt file is like this: { "ccAL":{ countryCode:"AL", countryName:"Albani&euml;", IBANlength:"28", bankFormCode:"0 8n 0 ", accountNum:"0 16 0 " }, "ccAD":{ countryCode:"AD", countryName:"Andorra", IBANlength:"24", bankFormCode:"0 4n 4n", accountNum:"0 12 0 " }, "ccBE":{ countryCode:"BE", countryName:"Belgi&euml;", IBANlength:"16", bankFormCode:"0 3n 0 ", accountNum:"0 7n 2n" } } */ What am I doing wrong. Tnx in advance

    Read the article

  • Reading option values in select

    - by user281180
    I have select values as follows: <select id="SelectBox" multiple="multiple"> <% foreach (var item in Model.Name) { %> <option value="<%= item.Value %>"><%=item.Text%></option> <% } %> </select> I have a function in jquery that will have to read both the text and value. I need to have the values in array so that I can display them in a table with a column Id and another column text. My problem is that Im not able to retrieve each and every value separately. Im having the text in one line, test1test2test3. function read() { $("#SelectBox").each(function() { var value = $(this).val(); var text = $(this).text(); alert(value);alert(text); }); }

    Read the article

1 2 3  | Next Page >