Chained Select Assistance


Hi I managed to get the tutorial from the below link to work.
http://www.blueicestudios.com/chained-select-boxes-using-php-mysql-ajax/comment-page-11/#comment-34199 I would love to know how to edit this script so as to get the first dropdown to populate an already existing dropdown without the loader image and without the hiding of any dropdowns. I would assume you only have to make changes to this section: $(document).ready(function() { $('#wait_1').hide(); $('#drop_1').change(function(){ $('#wait_1').show(); $('#result_1').hide(); $.get("func.php", { func: "drop_1", drop_var: $('#drop_1').val() }, function(response){ $('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); function finishAjax(id, response) { $('#wait_1').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } Your assistance is greatly appreciated
Posted On: Wednesday 28th of November 2012 12:36:39 AM Total Views:  70
View Complete with Replies

RELATED TOPICS OF JavaScript PROGRAMMING LANGUAGE




AJAX chained select

Hi ! I need a javascript code which sends variable to PHP. I have a drop down menu () in the select there are diffrent cities and i have an array of neighborhoods and when one city is selected, a part of that array shows up, e.g. from 13 to 28 I have the php code, just need the javascript that sends the variable depending on the selected city., Ok this is the drop down for the city: : The dropdown looks like this City 1 City 2 City 3 etc. This is how i get the array with neighborhoods: : , No no man, can AJAX send two variables to the PHP, one with the starting number and second with the finishing number.... Something like this if City 1 is selected the script sends var1=0 and var2=89, or if City 2 is selected the script sends var1=90 and var2=110 so the php script can get these two variables and get the neighborhoods from the array and display them :),
VIEWS ON THIS POST

91

Posted on:

Monday 19th November 2012
View Replies!

chained javascript menu. problem with displaing categories

part of index page -- BMW Audi -- 1 series 3 series 5 series 6 series 7 series A1 A3 S3 A4 S4 Find! $(function() { $("#series").chained("#mark"); }); js (function($) { $.fn.chained = function(parent_selector, options) { return this.each(function() { /* Save this to self because this changes when scope changes. */ var self = this; var backup = $(self).clone(); /* Handles maximum two parents now. */ $(parent_selector).each(function() { $(this).bind("change", function() { $(self).html(backup.html()); var selected = ""; selected = selected.substr(1); /* Also check for first parent without subclassing. */ /* TODO: This should be dynamic and check for each parent */ /* without subclassing. */ var first = $(parent_selector).first(); var selected_first = $(":selected", first).val(); $("option", self).each(function() { /* Remove unneeded items but save the default value. */ if (!$(this).hasClass(selected) && !$(this).hasClass(selected_first) && $(this).val() !== "") { $(this).remove(); } }); /* If we have only the default value disable select. */ if (1 == $("option", self).size() && $(self).val() === "") { $(self).attr("disabled", "disabled"); } else { $(self).removeAttr("disabled"); } $(self).trigger("change"); }); /* Force IE to see something selected on first page load. */ $("option", this).first().attr("selected", "selected"); /* Force updating the children. */ $(this).trigger("change"); }); }); }; /* Alias for those who like to use more English like syntax. */ $.fn.chainedTo = $.fn.chained; })(jQuery); show.php -- var car_m_s= $(function() { $("#series").chained("#mark"); }); , after i done selection in the form1, i press submit button and Im going to show.php page. on show.php page i want categories to be already selected. whats my problem
VIEWS ON THIS POST

152

Posted on:

Saturday 24th November 2012
View Replies!

Firefox and chained select menus

Hi all, I have a problem with a script that is driving me round the bend and I do hope someone can shed some light on the matter. I am new to Javascript and need a nudge in the right direction. I have three select menus - Country, Region and County. If you select a Country, the Region menu updates. If you then choose a Region, the County menu updates. I have used a script from GreatASP.co.uk and, after a small amount of fiddling and a large amount of swearing, I have this working in IE but Firefox doesn't even try: function getSelect(selectname,selection,recordset,destination){ if(selection!=''){ var doc = null; // Make a new XMLHttp object if (typeof window.ActiveXObject != 'undefined' ) { doc = new ActiveXObject("Microsoft.XMLHTTP"); } else { doc = new XMLHttpRequest(); } // Load the result from the response page if (doc){ doc.open("GET", "populate.aspselectname="+selectname+"&selection=" + selection+"&recordset="+recordset, false); doc.send(null); // Write the response to the div destination.innerHTML = doc.responseText; }else{ destination.innerHTML = 'Browser unable to create XMLHttp Object'; } }else{ // Return the next select box back to the default destination.innerHTML= ''; } selectname= null selection = null recordset = null } In the original version from GreatASP, the author puts the following line about the function declaration, but I have found that this actually stops the code from working in IE. // declare new variables for each new div that you add, and link to the div by ID var subcatdiv = document.getElementById("subcat_div"); Obviously, I changed the variable name and div name to suit. I can see what it's for, in that you have to define the variable before the function calls it - indeed, Firefox warns me in the error console if the above line(s) are not included, but still doesn't work when I put them in. It says regiondiv is not defined. The DOCTYPE of the HTML file is 4.01 Transitional if that helps at all. The HTML that calls the function is: Country1 Country2 I have tried replacing various parts of the code with getElementById calls but nothing seems to work. The above code is the only variation of dozens that seems to work in IE and I have never got it to do anything in Firefox. I realise I have 3 SELECTs called Area - this is because the form needs to produce a URL string that groups Country, Region and County together, separated by commas. Please help!
VIEWS ON THIS POST

65

Posted on:

Sunday 25th November 2012
View Replies!

Auto select current day/month in a dropdown

, I have this reservation form found on the main page of: http://www.avis.com.lb/ As you can see the current month "August" is selected as the default month and so is the year and day (the day is programmed to jump 2 days ahead for the renting of the car...) However if you look closely (check the screenshot attached) you'll see that the month "August" is repeated twice and so is the year "2009", the current month is repeated twice. What I wanna do is remove the duplication and just auto select the current month without duplicating it. I found this code: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_24229186.html But it doesn't seem to work with my form, I donno why. Here is the code of the script both javascript and a little bit of php $date = strtotime("+2 day"); $date2 = date('j',$date); $date4 = strtotime("+5 day"); $date3 = date('j',$date4); if($date3 == 1){ $nextmonth = strtotime("+1 day"); $monthid = date('m',$nextmonth); }else{ $nextmonth = strtotime("+0 day"); $monthid = date('m',$nextmonth); } if ($monthid==1){ $year = date("Y") + 1; }else{ $year = date("Y"); } //$pupday = date("j") - 12; //$pupday = date("d") + 2; //echo $pupday; //$returnday = date("d") +5; $month = date("F"); var xMonths = new Array( '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12' ); function getListValue( option_object ){return option_object[ option_object.selectedIndex ].value;} function setListValue( option_object, value ){ option_object.selectedIndex = value;} function addDays(myDate,days) { return new Date(myDate.getTime() + days*24*60*60*1000); } function init() { xToday = new Date(); yToday = addDays(new Date(),3); xMonth = xToday.getMonth(); xDay = xToday.getDate()-1; xYear = xToday.getYear()-2005; if (xYear < 2005) xYear=0; yMonth = yToday.getMonth(); yDay = yToday.getDate()-1; yYear = yToday.getYear()-2005; if (yYear < 2005) yYear=0; xF = document.forms['quickbooking']; setListValue( xF.ETAHour, 9 ) setListValue( xF.ETAMonth, xMonth ) setListValue( xF.ETADay, xDay ) setListValue( xF.ETAYear, xYear ) setListValue( xF.ETTHour, 9 ) setListValue( xF.ETTMonth, yMonth ) setListValue( xF.ETTDay, yDay ) setListValue( xF.ETTYear, yYear ) }
VIEWS ON THIS POST

120

Posted on:

Monday 26th November 2012
View Replies!

Printing a selected Table

Hi this is scorpionz, The Reason of this thread Let me put forward to all of the ladies and Gentlemen I have a Table which is split in different cells and columns Now in these Cells i have some table infact you can view the below code by just copy/paste and save with .html extension....Its a simple design view after running in Browser you can view three different tables with left, center , Right. and in the center table below is the 2 buttons with "Print It" and "Print View" What I want to do is, if i Press "Print It" then it Print the table with the id: id="recordb" It is a Center table with fields id, First Name, Last Name or if i Press "Print view" then It show that Table Print Preview of Id: id="recordb" Individually, I have create empty function with name , can be view below. But stuck what to write inside these...... Any Response will be highly appreciated with great Interest..... Untitled Document function printme() { } function printpreview() { }   Insert Update Delete Id First Name Last Name 12 abc xyz 15 ghj klm 53 qwe rty Poll        
VIEWS ON THIS POST

95

Posted on:

Tuesday 27th November 2012
View Replies!

persistant cookie for select function

Could Somebody Please Write Me a cookie For the following code I tried several Times But Nothing worked, I just dont understand cookie functions. I want a users selection to remain indefinately until they change it, at which point a new cookie is written. Please share your skill
Change The background

VIEWS ON THIS POST

312

Posted on:

Tuesday 27th November 2012
View Replies!

selecting html table row for deletion

I am trying to make a table that has following columns: site id,txn id,txn name,target id,target db there can be any number of rows in the table and each row has at least one different column entry with respect to other rows.Now i wish to delete from database data of the row that is selected.I was thinking that giving checkboxes alongside each row and then somehow passing id of this selected checkbox(s) to java class would help in extracting data of individual fields in the row which can than be deleted. Any ideas as to how to go about itIm using jsp,javascript,java and html for my application.
VIEWS ON THIS POST

106

Posted on:

Tuesday 27th November 2012
View Replies!

onClick html select box help, passing selected value?

, I'm workin on a little side project and I was looking for some help. Currently I have code that will check a given directory and populate two list boxes based on id3 tag information. The first select box will be populated with artist info and the second, with album info. What I want to do is use javascript to populate the second list box with the album info matching the artist selected, hence the "onChange" in the forum post title. Below is a portion of my code. I believe you can get the overall picture of what is going on. It has many calls to php methods that are not defined below but i think you can see what they are doing/returning etc. Could someone point me in the right direction of how to use javascript to populate the second select box only when an artist is selected and not before
VIEWS ON THIS POST

99

Posted on:

Tuesday 27th November 2012
View Replies!

Random CSS Stylesheet selector exists?

m looking for a Javascript function or similar which will automatically load a different stylesheet randomly each time a page is visited. I have found several which work on user selection, or on browser size. My Javscript coding isn't up to adapting them sad If anyone knows of an example, I'd appreciate the knowledge. It's just so that the user goes "Ohooh "
VIEWS ON THIS POST

63

Posted on:

Tuesday 27th November 2012
View Replies!

javascript to add select button

im trying to add one more row to my table...... this row will have select button,text fields that would also be generated..... the Select list have to take values from variable in jsp page.......... please can anyone tell me how to do that......... i have also attached a image file showing my case. In that i want that if user clicks add Process Skill button...... there is one more row inserted after the 3rd row........... this will have alll the form field with the values shown...... regards ankur i have attached a file. In that, Well, I'll correct myself then and say "msdn is one of the best" haha. And you're right, if of us started to use correctly formed DOM, then our live would be much easier... that's why my warning... So, we have 3 ways to populate those tables: 1 - Nasty innerHTML. 2 - MS way of managing tables. 3 - DOM way. (this one being the better, just a few more lines of coding). Now, question for alpha.. as I'm more experienced with IE, how does mozilla handles the cloned form elements names
VIEWS ON THIS POST

85

Posted on:

Tuesday 27th November 2012
View Replies!

Javascript - buttons select and unselect issue - JavaScript Help

I have a dropdown menu and some buttons below in my HTML: 1 2 3 4 What I want to know is that how is it suppose to be coded so that the user can only select the same amount of buttons as the number from the drop down menuFor example if the user selects the number 3 from the dropdown menu, then if the user clicks on a button, it will highlight the button in a color (lets say green) but the user can only have three buttons selected. If an additional button is clicked then that button would not be selected. The additional button can only be selected if the user unselects a selected button and then selects the button he wishes. This means that only 3 buttons can be selected at maximum. Also only 3 buttons minimum can be selected, if more or less buttons are selected than the number 3 then it should come up with an alert.Is this suppose to be done in Javascript or Jquery and how can I use css to change the color of the ubttons to green if selected or back to grey if unselectedThank You
VIEWS ON THIS POST

140

Posted on:

Tuesday 27th November 2012
View Replies!

select province/state for one country only - JavaScript Help

HiI would like to write a script where it lists all the countries of the venues in a drop down box.If south africa is selected it then shows the provinces in a second drop down box.If any other country is selected, then no province/state drop-down box is show
VIEWS ON THIS POST

102

Posted on:

Tuesday 27th November 2012
View Replies!

Disable textbox based on dropdown selection - JavaScript Help

Here's what I have. I can't get it to work for anything in the world... Static or Random Static Random Static ID function enableTextbox() { var val = document.getElementById("staticrand").selectedIndex; if (val == 'static') { document.getElementById("staticid").disabled = false} else { document.getElementById("staticid").disabled = true} }
VIEWS ON THIS POST

74

Posted on:

Tuesday 27th November 2012
View Replies!

element to change bgcolor - JavaScript Help

, trying to get a select element to change the background colour of my Div. However it doesn't work - it used to and i havn't changed anything. What is wrong
VIEWS ON THIS POST

131

Posted on:

Tuesday 27th November 2012
View Replies!

jQueryUI autocomplete--get value of selected - JavaScript Help

Probably a simple answer to this one...I need to use the select option on the autocomplete widget to change some data elsewhere on the page, but to do it, I need ot get the value of what was selected in the first place. What variable do I grab for that
VIEWS ON THIS POST

117

Posted on:

Tuesday 27th November 2012
View Replies!

how to get id of select menu? - JavaScript Help


VIEWS ON THIS POST

63

Posted on:

Tuesday 27th November 2012
View Replies!

Remove tags from selected text in textarea - JavaScript Help

I want to add button that remove tags (remove formating) from selected text in textarea. Here is my code for adding BBCode tags between selected text:function formatText(el,tagstart,tagend) { if (el.setSelectionRange) { el.value = el.value.substring(0,el.selectionstart) + tagstart + el.value.substring(el.selectionstart,el.selectionend) + tagend + el.value.substring(el.selectionend,el.value.length) } else { } }Than I just add another function for tags:function AddTag(tag) { formatText(document.getElementById('textarea'),'['+tag+']','[/'+tag+']'); }And add tag button will look like:This button will add [ b] and [ / b] between selected text in textarea.I have tried this code but this remove all tags, not just for selected text:function deleteTags(){ var tags=[ '\\[b\\]', '\\[\/b\\]', '\\[url\\]', '\\[/url\\]', '\\[u\\]', '\\[\/u\\]' ] var my = document.getElementById('mytextarea'), i=0, reg, t; while(t=tags[i++]){ reg=new RegExp(t,'gi'); my.value = my.value.replace(reg,''); } }How can I add another button to remove all tags ( [ b] , [ u ], [ quote ] etc...), but from selected text
VIEWS ON THIS POST

86

Posted on:

Tuesday 27th November 2012
View Replies!

how to: select onchange alter another field on same page - JavaScript Help

I have a multiple fields on my page and wish to have a reusable javascript to update the previous box with the selction made.how would this be done 1 2 3         1 2 3  
VIEWS ON THIS POST

122

Posted on:

Tuesday 27th November 2012
View Replies!

build a checkbox list based on selection of drop down form field - JavaScript Help

i want to build a checkbox list that displays information based on the selection from a drop down menu.So if someone selects cars i want a the following options to display as a checklistso it wold be .... cars->chevy, ford, nissan to be displayed in a checklist format, that way they can select the options they wantI'm really new to Javascript so i'm not sure how to start. I hope someone here can help me
VIEWS ON THIS POST

78

Posted on:

Tuesday 27th November 2012
View Replies!

Passing select value - JavaScript Help

Hi allI have a content loading scriptfunction ajaxLoader(url,id) { if (document.getElementById) { var x = (window.ActiveXObject) new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); } if (x) { x.onreadystatechange = function() { el = document.getElementById(id); el.innerHTML = ""; if (x.readyState == 4 && x.status == 200) { el = document.getElementById(id); el.innerHTML = x.responseText; } } x.open("GET", url, true); x.send(null); } }which works great.I then have a drop down HTML list which looks like Apple Dell Logitech I then have a SPAN areain which "product_list.php" loads in.all I want to do, is pass the value of whatever option was selectedSo if "Dell" was selected, the call would beonchange="ajaxLoader('product_list.phpvalue=2','contentarea');"and if "Apple" was selected, the call would beonchange="ajaxLoader('product_list.phpvalue=3','contentarea');"but using(this.value)doesn't seem to be passing the selected value in the listcan anyone help I'm totally stumpte
VIEWS ON THIS POST

36

Posted on:

Tuesday 27th November 2012
View Replies!