JavaScript - Editable Combo - Does Not Work In Ie
Hello all,
I have a form which contains some fields like company_name, address, phone, email etc. Also, I have a database with companies. I want that, when typing the beginning of the company name, a combo box to suggest all companies that match that text. I want that when a company is selected from the combo, all other textboxes to be filled with the correct info from the database. Also, I want that the user to be able to write a company that is not registered in the database. What I have done until now: For the editable combo I used the dhtmlxcombo from he http://dhtmlx.com/docs/products/dhtmlxCombo/ (Filtering mode: (filter existing list)). I'm not a scripting expert, so I think I cannot build this combo all by myself. I modified just one thing. At the begining, the dhtmlxcombo.js file contained something like this: Code: if (tab)z.tabIndex=tab;z.style.width = (width-19)+'px';self.DOMelem.appendChild(z);self.DOMelem_input = z;z = document.createElement('input');z.type = 'hidden';z.name = name;self.DOMelem.appendChild(z);self.DOMelem_hidden_input = z;z = document.createElement('input');z.type = 'hidden';z.name = (name||"").replace(/(\]?)$/, "_new_value$1");z.value="true";self.DOMelem.appendChild(z);self.DOMelem_hidden_input2 = z I added z.id='dest_company';, so the file looks something like this, now: Code: if (tab)z.tabIndex=tab;z.style.width = (width-19)+'px';self.DOMelem.appendChild(z);z.id='dest_company';self.DOMelem_input = z;z = document.createElement('input');z.type = 'hidden';z.name = name;self.DOMelem.appendChild(z);self.DOMelem_hidden_input = z;z = document.createElement('input');z.type = 'hidden';z.name = (name||"").replace(/(\]?)$/, "_new_value$1");z.value="true";self.DOMelem.appendChild(z);self.DOMelem_hidden_input2 = z};dhtmlXCombo_defaultOption.prototype._DrawHeaderButton = function(self, name, width) The text field 'dest_company' is generated like this: PHP Code: <select name="dest_company" id="dest_company" OnChange="SelectReceiver(document.comanda.dest_company.value);" style="width:206px;" tabindex="10"> <?php echo ' <option value=""></option>'; $address_result = mysql_query("SELECT * FROM `webdb_".$_COOKIE['user']."` ORDER BY companie ASC"); while($row = mysql_fetch_array($address_result)) { echo '<option value="'.$row['id'].'">'.$row["companie"].'</option>'; } echo ' </select> <script> var z = dhtmlXComboFromSelect("dest_company"); z.enableFilteringMode(true); </script>'; ?> This is the SelectReceiver() function: Code: function SelectReceiver(id_dest) { if (id_dest=="") { document.getElementById("contact_destinatar").value=""; document.getElementById("adresa_destinatar").value=""; document.getElementById("oras_destinatar").value=""; document.getElementById("judet_destinatar").value=""; document.getElementById("zip_destinatar").value=""; document.getElementById("telefon_destinatar").value=""; document.getElementById("mail_destinatar").value=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { //document.getElementById("detalii_destinatar").innerHTML=xmlhttp.responseText; var response = eval(xmlhttp.responseText); } } xmlhttp.open("GET","modifica_detalii_destinatar.php?q="+id_dest,true); xmlhttp.send(); } And the file modifica_detalii_destinatar.php looks like this: PHP Code: <?php $q=$_GET["q"]; include ('conectare.php'); $sql="SELECT * FROM `webdb_".$_COOKIE['user']."` WHERE id='".$q."'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { echo ' document.getElementById("contact_destinatar").value = "'.$row['contact'].'"; document.getElementById("adresa_destinatar").value = "'.$row['adresa'].'"; document.getElementById("oras_destinatar").value = "'.$row['oras'].'"; document.getElementById("judet_destinatar").value = "'.$row['judet'].'"; document.getElementById("zip_destinatar").value = "'.$row['zip'].'"; document.getElementById("telefon_destinatar").value = "'.$row['telefon'].'"; document.getElementById("mail_destinatar").value = "'.$row['mail'].'"; '; } ?> All this is working just in Firefox. In IE, when I select a company from the combo box, an error is generated and no text box is completed with the correct data. The error I'm talking about is: Code: 'document.comanda.compania_destinatar.value' is null or not an object In Firefox, if I inspect element with Firebug, my select looks like this: Code: <div style="width: 204px;" class="dhx_combo_box "> <input type="text" autocomplete="off" class="dhx_combo_input" tabindex="10" style="width: 185px;" id="companie_dest"> <input type="hidden" name="dest_company" value="45"> <input type="hidden" name="dest_company" value="false"> <img class="dhx_combo_img" src="codebase_xcombo/imgs/combo_select.gif"> </div> Any help on this would be great. Many thanks and best regards! Similar TutorialsHello I'm using the combo box selection menu by Elviro Mirko from this site (http://www.javascriptkit.com/script/...plecombo.shtml) I have made amendments to show my own data, however what I would like to happen is if the user selects from the top combo only, then all the records would be shown, whereas selecting from the second combo merely 'drills down' and shows the records required. - Hope that makes sense. The code is as follows: Code: // first combo box data_1 = new Option("Douglas - DIS", "$"); data_2 = new Option("Douglas - COE", "$$"); data_3 = new Option("Peel - DIS", "$$$"); data_4 = new Option("Peel - COE", "$$$$"); data_5 = new Option("Ramsey - DIS", "$$$$$"); data_6 = new Option("Ramsey - COE", "$$$$$$"); data_7 = new Option("Castletown - DIS", "$$$$$$$"); data_8 = new Option("Castletown - COE", "$$$$$$$$"); // second combo box data_1_1 = new Option("Registry Office Douglas", "-"); data_1_2 = new Option("Broadway Baptist Church Douglas", "-"); data_1_3 = new Option("Finch Hill Congregational Church Douglas", "-"); data_2_1 = new Option("St Thomas's Church", "--"); data_2_2 = new Option("St Barnabas Church", "--"); data_2_3 = new Option("St George's Church", "--"); The HTML code is as follows: Code: <select name="combo0" id="combo_0" onChange="change(this);" style="width:200px;"> <option value="">Select a Register...</option> <option value="Douglas - DIS">Douglas - DIS</option> <option value="Douglas - COE">Douglas - COE</option> <option value="Peel - DIS">Peel - DIS</option> <option value="Peel - COE">Peel - COE</option> <option value="Ramsey - DIS">Ramsey - DIS</option> <option value="Ramsey - COE">Ramsey - COE</option> <option value="Castletown - DIS">Castletown - DIS</option> <option value="Castletown - COE">Castletown - COE</option> </select> <BR><BR> <select name="combo1" id="combo_1" onChange="change(this)" style="width:200px;"> <option value="">Select a venue...</option> </select> the link for the actual site is http://www.manxbmd.com/cgi-bin/db.cg...m;db=marriages If you choose Douglas-COE and search, then 0 records are found, if you choose Douglas-COE followed by St Thomas's then still 0 records are found but if you search the surname Allitson you'll see that there is a record there. I'm not sure where I've gone wrong - I'm completely new to Javascript. Any suggestions welcomed. regards Pendle Hi Everybody This is probably a very commonly asked question, however after much searching online I can't seem to find a straightforward answer. If anyone knows the code or a link to a place with a simple example it would be great. What I have got is a form that a user has to fill out and submit (when validated all variables are stored in a session and emailed after multiple forms are completed), currently I have radio buttons, text boxes and a combo box/ drop down list (for location). All parts are working fine and validating fine. My problem is to do with the combo box//ddl. I have successfully validated the ddl so the user must select a location onsubmit and it is added to session and passed fine. At the moment the ddl only has cities or towns in it however as I would like to include different states and possibly different countries I need a code that validates the state first and then only gives the cities/towns that are in that state (otherwise my ddl would be to large). I can do this with links however I can't seem to do it in a form. I am trying to do it this way DDL has list of all states that on mouseover/ onclick the list is revealed. onclick of a specific state populates another ddl with only the cities cities/ towns that are in that state and onclick of specific city selects the location whereby onsubmit the location is stored in the the session for submission by email Thanks in advance for your help I still have the following two major issues. 1) Firstly I need to be able to send the selection from the second combo box by php. 2) secondly I need the combo box to appear within the table. (I thought this should be easy, but for the life of me cannot figure out how to get the dynamic combo into my table inside the form) I have managed to send the selection from the first combo box with the form and also I can send a selection from the second combo, however onsubmit regardless of what is selected in the second combo box it simply sends the last option not the one selected. I have spent many hours trying to figure out why this is the case to no avail. I have included my code for anyone who may be able to help. Lastly when I have figured out these 2 (with a little help) I should be able to sort out the validation by myself. Please ignore any code that is not relevant <html> <head> <script type="text/javascript"> var this1; window.onload = function() { if (!document.all) document.captureEvents(Event.CHANGE); document.getElementById('myddl').onchange = readDDL1; } function readDDL1() { var ddlobj = document.getElementById('myddl'); var currentSelection = ddlobj.options[ddlobj.options.selectedIndex].value; if (currentSelection == '') currentSelection = ddlobj.options[ddlobj.options.selectedIndex].text; doDDL2(currentSelection); } function doDDL2(ddl1Selection) { var existingDDL2; if ((existingDDL2 = document.getElementById('myddl2')) != null) existingDDL2.parentNode.removeChild(existingDDL2); var ddl2Options; switch (ddl1Selection) { case "Western Australia": ddl2Options = ["Please Select A Location", "Karratha", "Perth"]; break; case "Queensland": ddl2Options = ["Please Select A Location", "Brisbane", "Gold Coast"]; break; } if (typeof ddl2Options == "object") { ddl2 = document.createElement('select'); ddl2.id = "myddl2"; var forVar; for (forVar in ddl2Options) { var newOption = document.createElement('option'); newOption.appendChild(document.createTextNode(ddl2Options[forVar])); ddl2.appendChild(newOption); } document.body.appendChild(ddl2); } document.testform.this1.value = ((ddl2Options[forVar])); } function checkFrequency() { return ShowResults(); } function validate(){ var digits="0123456789" var temp if (document.testform.location.selectedIndex == 0) { alert("Please Select a State"); return false } if (document.testform.location2.selectedIndex == 0) { alert("Please Select a Location"); return false } return true } </script> <style type="text/css"> .td_freq { background-color:yellow; height:40px; text-align:center; } .td_sev { background-colorink; height:40px; text-align:center; } .td_wi { background-color:lightgreen; height:40px; text-align:center; } </style> </head> <body> <FORM name="testform" action='./emlapd.php' method='post' onsubmit="return checkFrequency()"> <input type='hidden' name='this1'> <table align="center" border="1" width="40%"> <tr><td><b>Current Worksite State:</b><font color="red">*</font></td> <td> <select name="location" width='53' id="myddl"> <option value="0">--- Please Select Your State --- & nbs p; & n bsp; & nbs p; </option> <option value="Western Australia">Western Australia</option> <option value="Queensland">Queensland</option> </select> </td></tr> <tr><td><b>Location:</b><font color="red">*</font></td> <td> </td></tr> </table> <tr> <th colspan="2"> <input type="submit" name='submit' value="Submit" onclick= "return validate()"> </th> <td colspan="10"> </td> <th> <input type='reset' name='reset' value='Clear Form'> </th> </tr> </table> </FORM> </body> </html> Thankyou very much to everyone that may help So I can place the DDL inside the form, however it places it at the end of the form. I want it somewhere in the middle (immediately following first combo box) My other main issue is irregardless of the selection it simply posts the last option from the DDL not the one selected. Therefore I still want the second combo box to appear immediately below the first combo box and whatever option is selected from the second combo box I want to be posted with the rest of the form data. If you have any other ideas that would be great Obviously the reason I am still getting the same incorrect post is because the variable posted is still this1 from my code which reads the last value from the DDL. I have tried with all other variables to send as well ie ddl2 however still can't seem to send the selection. So in its current state how can I send the selection and place the second DDL within the form?? Thank you I have created an editable grid based on: http://www.webismymind.be/editablegrid Although I have created a few basic sites - coding is still pretty new to me, but what I want to do is make this grid editable by an admin user - and then have other users who can view it but not edit it. I am trying to create a basic staff rota & any help would be much appreciated Thanks Please could someone tell me the JavaScript to allow the user to edit the content in an iframe, but I need to know if it will allow the user to edit the iframe in all browser types.
Hi, "I need editable table with calculations in javascript" "I have a table in that table i have 4 column like mark1,mark2 and total. if i give input to that specific cell the total is automatically calculate. Please send any code or any related links". I tried below code... <html> <head> <title>sample dynamic select list</title> <script language='javascript'> function changeContent(tablecell) { //alert(tablecell.firstChild.nodeValue); tablecell.innerHTML = "<INPUT type=text name=newname onBlur=\"javascript:submitNewName(this);\" value=\""+tablecell.innerHTML+"\">"; var u1=document.getElementById('m1').value; var u2=document.getElementById('m2').value; res=u1*u2; document.getElementById('t').innerHTML=res; tablecell.firstChild.focus(); } function submitNewName(textfield) {//alert(textfield.value); textfield.parentNode.innerHTML= textfield.value; // textfield.parentNode.innerHTML= res; } </script> </head> <body> Double click on any cell. Then enter your own text and then tab out or click on other place. <table border=1 bgcolor=gray> <tr> <th onDblClick="javascript:changeContent(this);">Mark1</th> <th onDblClick="javascript:changeContent(this);">Mark2</th> <th onClick="javascript:changeContent(this);">total</th> </tr> <tr> <td onDblClick="javascript:changeContent(this);" id="m1">10</td> <td onDblClick="javascript:changeContent(this);" id="m2">20</td> <td onClick="javascript:changeContent(this);" id="t"></td> </tr> </table> </body> </html> I got it editable table but i cannot able to add two cell and also assign result to total.. let u know please help me Thanks I have a dropdown menu. the code is as below: <html:select name="data1" property="accountNumber" styleClass="formContent" > <option>Id1 </option> <option>Id2 </option> I need to give user an option to select from the list or enter a new value. how do you do this ? I can add another option say "new value" and when he choose this user should be able to add the new value/ please help !! I'm new to java script. I have 2 questions. Can I have draggable editable images? I can make my images movable around the page, but I would like to be able to make the images editable and have the text follow the images. I would like to either have a drop down menu or buttons that can make the images displayed on the page then edit them and move them to my map location on the page. Is this possible, and thanks for any help guys. Here is the code I used for the movable images. Code: <img src="images/loconorth.gif" class="dragableElement" style="float:left"> <img src="images/locosouth.gif" class="dragableElement" style="float:left"> <img src="images/Loco east.png" width="80" height="36" class="dragableElement" style="float:right"> <p> <p><img src="images/Loco west.png" width="80" height="36" class="dragableElement" style="float:left"> hi, i need to be able to allow a user to past into an editable div (via whatever the user chooses: right-click and paste, shortcut key, etc), but i want to discard formatting and only take the plain text. i can't use a textarea since the div will allow basic formatting (bold and italic) if applied by user-initiated events. the onbeforepaste event looked promising, but according to quirksmode the support is so limited as to be unusable. i searched the board, so apologies if this has been asked and answered. tyia for any suggestions. Hello all, I am using an editable iframe to change the style of the text as a person enters text depending on what they type in. Sometimes the text needs to be a link, and while inserting a link works, I can't click on it. I was wondering if anyone knows how to get links in an editable iframe to click through. I've researched this for a while now without getting anywhere. Right now I'm guessing that I need to somehow find out if the user is hovering over a link and turn "designMode" off for that section of text, or the whole iframe, I'm not completely sure. Anyway, any help would be greatly appreciated! How do I get the pixel position of the caret in an editable IFrame? I am building a WYSIWYG editor which works for Gecko, Trident, Webkit and Presto. I am doing this by setting the designMode to 'on' for an IFrame. The problem that I am having is that I need to know the pixel position of the caret so I can determine if the caret is at the bottom of the page. The reason I want the pixel position is so that way I can auto scroll the scrollbar to that position. I should mention that we are using JavaScript. Any ideas appreciated. Hi all, I'm trying to get the cursor position to move to the end of the text within an editable iframe or div. I've been pointed to something called TextRange and have been reading up on it for days yet couldnt make sense of much (i'm still very new). what i'm trying to do is on a button click, the cursor will move to the end of the text in the iframe. any help or pointers would be greatly appreciated. thanks. Hello I have several issues with my multilevel drop down menu The First issue is : the page has 2 iframes (one has the horizontal multilevel drop down menu on the top) the below iframe has my site address Now, when i hover over the menu it does not open or expand but when i open just the menu without any iframes it does This clearly means that the menu is not coming out of the iframe Please help me bring it on top of everything of the page Note: i have placed the menu in one iframe and a page opens below it in another iframe. The Second issue is : I want the navigation bar that is the multilevel drop down menu to be editable Which means i have a blog and a forum on my site but my visitor wants that the blog should not appear there and another link to play games should be there and hence he/she can edit it And please also try to make it work on cookies so that the user info and preferences are saved in cookies and whenever he/she comes back they see the page their way. For you: I would like to tell you that IdeaLab has launched a Twitter Advertising, Widget and Search platform and the first 1000 people are getting $100 go to tweetup.com Please help me, it will be really appreciable. Thank you very much in advance! Hi @ all! I've a div that is editable (contentEditable = true). The div has a fixed size like a letter page. When the user has written so much text that the text overflows I want add a new div above and let flow the overflown text in the other div. (it's the some behavior like MS Word in page view, but now it is in the web) It is possible to do something like this in the web? One way to implement this is to check if the text of the div overflows (I've found java script examples in the web which do that). And than I need the text that overflows to move it to the next div. But I have not found a function that do this. Is there such a function? Another way is to insert a gap at that position a new page begins and use an background image that looks like a page border. With this solution, the whole text is in one div but it looks like floating to another page. But therefore, I have to add a gap between to lines at a specific position (the page border/margin and the gab between the pages). Does anyone have an idea how to realize this? Maybe there are other possibilities to find a solution, aren't there? I hope, you have understand what I want to realize. If not, please feel free to ask me! Thank you for answers and hint in advanced! Konstantin Hello, I am very new to HTML and PHP but have managed to create a drop down "Surname" box on my website to list all the current surnames in my mySQL database. However, I also want the user to be able to type into the box and for the drop down list to automatically filter depending on the text the user inserts. I understand that this is not possible in HTML and PHP and requires some JavaScript, however I have never used this before and have no idea where to start. Any suggestions or help will be much appreciated. Here is my current HTML and PHP code... Code: $sql="SELECT Surname FROM Patients"; $result=mysql_query($sql); ?> <form name="form" method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>"> Surname: <?php echo "<select name=\"surname\">"; echo "<option size =30 ></option>"; while($row = mysql_fetch_array($result)) { echo "<option value='".$row['Surname']."'>".$row['Surname']."</option>"; } echo "</select>"; ?> Thank you! Hi I am doing a java program. In which I have a jsp page, and on that I have two combobox. I have a create a java bean, in which I am extracting the database. I want to populate the combobox by extracting data from database. can anyone suggest me some code using java script , which i can use to populate my combobox. Thanks in advance I have 2 combo boxes where you can move the items in combo box 1 to combo box 2. I want to validate that combo box 2 actually has something moved to it. How can I count the items in combo box 2. Combo box 2 will initially have no items in the box on page load. It is up to the user to move the items to combo box 2 and I want to make sure at least 1 item was moved.
Hi all, I have a form which takes some values as input and stores them in a db for another use. I have the following java script to validate the entries. Code: <HTML><HEAD><TITLE>Electronic Deposting Form</TITLE> <script language="JavaScript"> <!-- script start function validateComplete(formObj) { if (emptyField(formObj.username)) alert("Please enter the Username."); else if (emptyField(formObj.passwd)) alert("Please enter the Password."); else if (emptyField(formObj.drop)) alert("Please enter the Drop Folder."); else return true; return false; } // Check to see if field is empty function emptyField(textObj) { if (textObj.value.length == 0) return true; for (var i=0; i<textObj.value.length; ++i) { var ch = textObj.value.charAt(i); if (ch != ' ' && ch != '\t') return false; } return true; } function chklen() { var un = document.getElementById("username").value var len = un.length; if (len > 15) { alert ("ERROR!!Only 15 characters are allowed in Username!!"); document.getElementById("username").value = un.substring(0,15); // remove excess characters } } // script end --> </script> Now I am planning to add a combo box to the form where I have the environment field. Following is the code for the form. Code: <td align="left" valign="top"><FORM name="form" action="../saveDP.cgi" method="post" onSubmit="return validateComplete(document.form)"><TABLE width="100%" cellPadding=2 cellSpacing=2> <TR> <TD width="26%" class="label"><B>Username </B></TD> <TD width="3%" class="label">:</TD> <TD width="71%"><INPUT maxLength=255 size=28 name=username id='username' onkeyup="chklen()"> <TR> <TD class="label" ><B>Password </B></TD> <TD class="label">:</TD> <TD><INPUT type=password maxLength=255 size=28 name=passwd> <TR> <TD class="label"><B> Environment </B></TD> <TD class="label">:</TD> <TD><SELECT class="input" size=1 name=environ> <OPTION value=us selected><b> US </b></OPTION> <OPTION value=uk><b> UK </b></OPTION> </SELECT> </TD> </TR> <TD colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="19%"> </td> <td width="9%"><INPUT type=submit value=Submit v:shapes="_x0000_s1034"> </td> <td width="8%"><input type=reset value=Clear v:shapes="_x0000_s1035\"></td> <td width="64%"> </td> </tr> </table></TD> </TR> As I am new to JS, can anybody help me to implement a combo box( ie first two options are US and UK and third one is a text box which i can enter any value, can't be left blank while submitting the form) with "Environment" field? On a friend's site I am using a combination of easyslider (a slideshow script) and lytebox (probably doesn't need an intro). It can be seen in action on http://www.maisonportier.com/menu.php (then click on 'Press'). I really don't know much about Javascript so am just able to do extremely simple things such as combining two script. Now my friend want the slideshow to pause when an image is opened (using Lytebox), and to continue when the image is closed. The scripts can be found at: http://www.maisonportier.com/js/lytebox.js and http://www.maisonportier.comeasySlider1.5.js Can anybody tell me how to modify the code? Any help is greatly appreciated! Hi, i have a form that uses POST but the post url also has some parameters with it. But i want the parameters to changing depending on a few combo boxes on the page. So what i want to happen is when the combo box is changed it sets a variable and that variable is some how used in the URL link within the HTML. Ive tried writing a function that gets the text of the combo as it changes by alert me with a popup. But when i try to use document.write to add my var in HTML it simple wont show. Am i doing this all wrong? Thanks andy |