JavaScript - Ckeditor Problem - Onkeypress
Similar TutorialsI have multiple input fields that use the onkeypress event to fire off the a submit button to run a makeRequest. On Firefox everything works great but in IE 7 and 8 no matter which input field your curser is in it always does the very first input field/makeRequest as well. Code: <fieldset> <legend>Test if mail server accepts email for a user.</legend> <div class="reportlabel">Enter the email address you wish to test.</div> <input name="mailbox_name" class="reportinput" type="text" value="" size="34" id="mailbox_name" onkeypress="if (event.keyCode == 13) document.getElementById('mailbox_submit').click();" /> <input name="Submit" type="submit" class="submit" name="mailbox_submit" id="mailbox_submit" value="" onClick="pingRequest('tools/mail_test.php?mb=' + document.getElementById('mailbox_name').value + '&test=mailbox', 'mb_div');" /> <div id="mb_div"></div> </fieldset> <div style="height:25px;"> </div> <fieldset> <legend>Test if domain has a mail server and it accepts mail.</legend> <div class="reportlabel">Enter the domain you wish to test.</div> <input name="accept_email" class="reportinput" type="text" value="" size="34" id="accept_email" onkeypress="if (event.keyCode == 13) document.getElementById('accept_submit').click();" /> <input name="Submit" type="submit" class="submit" name="accept_submit" id="accept_submit" value="" onClick="blRequest('tools/mail_test.php?domain=' + document.getElementById('accept_email').value + '&test=accept', 'email_div');" /> <div id="email_div"></div> </fieldset> Ive tried onkeydown, onkeyup everything gives the same result. Any help on the this would be greatly appreciated. Thanks Good day! In my javascript code I have a function for the enter key. I want to add cursor key in that function/ I research about the coding for cursor key but I can't find the code same on what I want to happen. Here is the code: Code: <script language="javascript"> function handleEnter(e, nextfield) { var characterCode = (e && e.which)? e.which: e.keyCode; if(characterCode == 13) { document.getElementById(nextfield).focus(); return false; } else { return true; } } </script> <input type='text' name='plt' onkeypress='return handleEnter(event,\"b0\");' /> Thank you Hi folks, I have the problem on using onKeyPress Event. I added one TextArea button to my form and wrote the validation script of max 10 characters for this TextArea. The code is like as shown below: <script type="text/javascript"> function isMaxLength( posDesc) { var desc = posDesc.value if( desc.length >10) { alert( "10 characters "); posDesc.value = desc.substring(0,10); posDesc.focus(); } } </script> </HEAD> <BODY> <TEXTAREA NAME =POSITION_DESC ROWS =2 COLS = 25 MAXLENGTH = 10 onKeyUp ="isMaxLength(this);" WRAP = VIRTUAL >position</TEXTAREA> </BODY> --> while entering the 11 th character the onKeyPress Event fires and displays alert message. And it replacing the 10 th index character with 11th new character. Here i do not want to update 10th index character. i want to remove 11th index character from textarea. For OnKeyUp Event it is working fine but this event would not filtering the ctrl,alt,shift characters. I am new for Javascript , please help me. regards, prakash. Ok so here I sit trying to go in and edit certain aspects of the RTE. (Rich Text Editor) You will see the attachment, we're trying to get rid of - Formatted - Address - Normal (Div) I've edited the file located @ ckeditor/_source/plugins/format/plugin.js And I've removed the obvious that allow it and I just cannot find out why it isn't removing individual elements. Hopefully someone will know what's going on. Thanks... hi i in my project use of CKeditor i need Access to event save it namely i want user on click on button save i do a action please help me how to it do thanks I'm fairly new to JS so sorry in advance if this is a stupid question! I have a textarea which uses ckeditor to make it a wysiwyg. I also have a bit of JS which watches the ckeditor and when a user types into it, whatever they type appears in a div elsewhere on the page. My ckeditor allows the text to be bold, italic, underlined and resized. When I apply styles to the text in the ckeditor textarea, I want them to reflected in the div which updates. At the moment only underline and resizing the text works. Choosing bold or italic does nothing the text updates ok, but no bold or italic. I've been told: "Ckeditor is using strong for bold, em for italics. My guess is that the browser or framework you are using doesn't apply bold and italics styles to those tags. You'll have to do that yourself." I've tested on several browsers, I checked in FF Opera Safari Chrome IE8 & IE9 and its the same in all them. Underline works, resize works but neither bold or italic do. (Interestingly in IE7 bold and italic do work as well as the size and underline! What's going on with that?!?) So I assume it is the framework? Can anyone tell me if this is right and if so, how do I go about doing that myself? heres the JS I'm using to update the div: Code: <label for="editor1">Background Story</label> <textarea id="editor1" name="editor1">This is sample text</textarea> <div id="story"></div> <script type="text/javascript"> CKEDITOR.replace( 'editor1' ); timer = setInterval('updateDiv()',100); function updateDiv(){ var editorText = CKEDITOR.instances.editor1.getData(); $('#story').html(editorText); }</script> hello all I'm trying to get the textarea text editor plugin CKEditor to work on my project. I'm using cakephp and following this simple tutorial amilan.wordpress.com/2010/01/28/ckeditor-integration-in-cakephp which basically tells that once I've included jquery and ckeditor then all I need to do to create a ckeditor textarea is: echo $form->textarea('content', array('id'=>'content','class'=>'ckeditor')); That all works fine except I can't resize the textarea at all. I've tried with css and putting 'cols' and 'rows' in there but to no avail. When I remove the ckeditor class it does work so I think it's something to do with the config. There is a config.js file which you can fiddle with but I don't know enough to know what to do to alter the height and width. Can anyone help me? The relevant bit of the documentation is http://docs.cksource.com/CKEditor_3....Configurations thanks if anyone can help me Hi pals, I am really tired in this problem of event keyup. I given same in my keyup function like: $(document).ready(function () { alert("GGG"+parseInt(jQuery.browser.version)); //To display test value working $("#find_text").keyup(function(e) { if(e.which == 13) { alert('Enter key was pressed'); //enter Here alert("FFF"+parseInt(jQuery.browser.version)); //Here got Error } }); }); I got Error : jQuery is not defined alert("FFF"+parseInt(jQuery.browser.version)); I use keycode,which , but no help, It's Work nicely in Chrome Browser but not in FF. Please give a Solution reply ASAP, I am really Tired.The code enter the Condition But that jQuery part make error. Thankfully Anes P.A For help I m putting it all together ..copy and paste and run ... I used 2 browsers IE and mozilla... you fill find the problem ...I know some one will definatly solve my problem ..... Code: <script type="text/javascript" language="JavaScript"><!-- function ManageTabPanelDisplay() { var idlist = new Array('tab1focus','tab2focus','tab3focus','tab4focus','tab1ready','tab2ready','tab3ready','tab4ready','content1','content2','content3','content4'); if(arguments.length < 1) { return; } for(var i = 0; i < idlist.length; i++) { var block = false; for(var ii = 0; ii < arguments.length; ii++) { if(idlist[i] == arguments[ii]) { block = true; break; } } if(block) { document.getElementById(idlist[i]).style.display = "block"; } else { document.getElementById(idlist[i]).style.display = "none"; } } } //--></script> <style type="text/css"> .tab { font-family: verdana,sans-serif; font-size: 12px; width: 100px; height:30px; white-space: nowrap; text-align: center; border-style: solid; border-color: #9a9a9a; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 0px; padding-top: 5px; padding-bottom: 5px; padding-left:3px; padding-right:3px; cursor: pointer; } .tabhold { background-color:#9a9a9a; /*color of menu #666666*/ color: white; } .tabfocus { background-color:white; color: #666666; } .tabcontent { font-family: sans-serif; font-size: 12px; height: 320px; border-style: solid; border-color: #9a9a9a; border-width: 1px; padding-top: 15px; padding-left: 10px; padding-right: 10px; overflow-y:scroll;overflow:-moz-scrollbars-vertical; } </style> <table border="0" cellpadding="0" cellspacing="0" > <tr > <td> <div id="tab1focus" class="tab tabfocus" style="display:block; padding-top:10px; height:39px;" > Overview </div> <div id="tab1ready" class="tab tabhold" style="display:none; padding-top:10px;height:39px;"> <span onclick="ManageTabPanelDisplay('tab1focus','tab2ready','tab3ready','tab4ready','content1')" >Overview </span> </div> </td><td > </td><td> <div id="tab2focus" class="tab tabfocus" style="display:none;"> Dimensions <br /> & Details </div> <div id="tab2ready" class="tab tabhold" style="display:block;"> <span onclick="ManageTabPanelDisplay('tab1ready','tab2focus','tab3ready','tab4ready','content2')">Dimensions <br /> & Details</span> </div> </td><td > </td><td> <div id="tab3focus" class="tab tabfocus" style="display:none;"> Quantity <br /> & Constructions </div> <div id="tab3ready" class="tab tabhold" style="display:block;"> <span onclick="ManageTabPanelDisplay('tab1ready','tab2ready','tab3focus','tab4ready','content3')">Quantity <br /> & Constructions</span> </div> </td> <td > </td><td> <div id="tab4focus" class="tab tabfocus" style="display:none;"> Customization <br /> Options </div> <div id="tab4ready" class="tab tabhold" style="display:block;"> <span onclick="ManageTabPanelDisplay('tab1ready','tab2ready','tab3ready','tab4focus','content4')">Customization <br /> Options </span> </div> </td> <td width="100%"> </td><td> </tr> <tr > <td colspan="8" > <div id="content1" class="tabcontent" style="display:block;"> content1 </div> <div id="content2" class="tabcontent" style="display:none;"> content2 </div> <div id="content3" class="tabcontent" style="display:none;"> content3 </div> <div id="content4" class="tabcontent" style="display:none;"> content4 </div> </td></tr> </table> please help thanks Code: <html> <head> <!-- CIS 340 Final Webpage project Author: Jeffrey Faulkner Date: 04/27/2011 File name: Mailinglist.htm --> <title>Home</title> <link href="mario.css" rel="stylesheet" type="text/css" /> <script src="random.js" type="text/javascript"></script> <script src="ads.js" type="text/javascript"></script> <script type="text/javascript"> function valmail() { var lastName = document.Infoform.LastName.value; var firstname = document.Infoform.FirstName.value; var mi = document.Infoform.Mi.value; var address = document.Infoform.Address.value; var city = document.Infoform.City.value; var state = document.Infoform.State.value; var zip = document.Infoform.Zip.value; var phone = document.Infoform.Phone.value; var dob = new Date (document.Infoform.Dob.value); var res = document.Infoform.chkResident.value; var email = document.infoform.email.value; var cemail = document.infoform.cemail.value; var stuClass; var classChecked = false; var selectnews = document.getElementById('lstF_ID'); var advisor = selectnews.options (selectnews.selectedIndex).innerHTML var radio = document.Infoform.Class.value; for (var i=0; i < document.Infoform.Class.length; i++) { if (document.Infoform.Class[i].checked) { classChecked = true; stuClass = document.Infoform.Class[i].value; } } if (lastName == "") { alert ("Please enter a last name"); document.Infoform.LastName.select(); return false; } else if (firstname == "") { alert ("Please enter a first name"); document.Infoform.FirstName.select(); return false; }else if (address == "") { alert ("Please enter a address"); document.Infoform.Address.select(); return false; } else if (city == "") { alert ("Please enter a city"); document.Infoform.City.select(); return false; } else if (state == "") { alert ("Please enter a state"); document.Infoform.State.select(); return false; } else if (zip == "") { alert ("Please enter a zip"); document.Infoform.Zip.select(); return false; } else if (phone == "") { alert ("Please enter a phone"); document.Infoform.Phone.select(); return false; }else if (dob == "NaN") { alert ("Date of Birth is not valid, use MM/DD/YYYY to enter data"); document.Infoform.Dob.select(); return false; }else if (Class.checked == "false"){ alert ("No class selected"); return false; }else if (email != cemail){ alert ("emails are not the same."); return false; }else { alert ("Last name: " + lastName + "\n" + "First Name: " + firstname + "\n" + "mi: " + mi + "\n" + "Address: " + address + "\n" + "City: " + city + "\n" + "State: " + state + "\n" + "Zip: " + zip + "\n" + "phone: " + phone + "\n" + "Date of Birth: " + dob + "\n" + "Advisor " + advisor + "\n" + "classfication " + stuClass); return true; } } </script> </head> <body> <h5><script type="text/javascript"> rNumber = randInt(5); //generate a random integer from 1 to 5 rAd = adDescription(rNumber); // description of the random ad rLink = adLink(rNumber); // url of the random ad document.write("<a href=" + rLink + ">"); document.write("<img src='ad" + rNumber + ".jpg' alt='" + rAd + "' />"); document.write("</a>"); </script></h5> <hr /> <a href="Home.htm">Home</a> <a href="speedrun.htm">Speed Runs</a> <a href="History.htm">History</a> <a href="mailinglist.htm">Mailing List</a> <a href="games.xml">List of games</a> <hr /> <h5><h3>Mario Mailing List</h3></h5> <h5><h3><form name="Infoform" action="action%20marker" id="Infoform" onSubmit="valmail()"> <table align="center"> <tr> <td> Last Name:</td> <td><input type="text" name="LastName" size="20" /></td> <td></td> <td></td> <td><h4>Class:</h4></td> <td></td> </tr> <tr> <td> First Name:</td> <td><input type="text" name="FirstName" size="20" /></td> <td></td> <td><input type="radio" name="Class" value="Mail" /></td> <td>Mail<td> </tr> <tr> <td> MI:</td> <td><input type="text" name="Mi" size="5" /></td> <td></td> <td><input type="radio" name="Class" value="email" /></td> <td>Email</td> </tr> <tr> <td> Address:</td> <td><input type="text" name="Address" size="20" /></td> <td></td> <td><input type="radio" name="Class" value="email" /></td> <td>phone</td> </tr> <tr> <td> City:</td> <td><input type="text" name="City" size="20" /></td> <td></td> <td><input type="radio" name="Class" value="text" /></td> <td>text</td> </tr> <tr> <td> State:</td> <td><input type="text" name="State" size="5" /></td> <td></td> <td><input type="radio" name="Class" value="any" /></td> <td>any</td> </tr> <tr> <td> ZIP Code:</td> <td><input type="text" name="Zip" size="20" /></td> <td></td> <td></td> <td></td> </tr> <tr> <td> Phone:</td> <td><input type="text" name="Phone" size="20" /></td> <td></td> <td><input name="chkResident" type="checkbox" /></td> <td> All the above</td> </tr> <tr> <td> Date of Birth:</td> <td><input type="text" name="Dob" size="20" /></td> <td></td> <td>What news do you want to here about?</td> <td><select size="1" name="lstF_ID"> <option selected="selected" value="1">New speed runs</option> <option value="2">upcoming games</option> <option value="3">New bugs found</option> <option value="4">new speed runs</option> <option value="5">All</option> </select value="1"></td> </tr> <tr> <td> EMail:</td> <td><input type="text" name="email" size="20" /></td> <td></td> <td></td> <td></td> </tr> <tr> <td> confirm email:</td> <td><input type="text" name="cemail" size="20" /></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td><input type="submit" value="Submit" /></td> </tr> </table> </form></h3></h5> </body> <hr /> <address> All information taken from mario wiki </address> </html> I have looked at this for an hour and i can not find anything wrong this is coder javascript : textneu = textneu.replace(/haha/,"<img src='../images/21.gif'>"); Result: <img src='../images/21.gif'> why? i want result is : <img src='../images/21.gif'> hi at all!!! I'm new in this forum. I have a problem and I need your experience in js! I have one page in html, but that is build only with js and css3. My problem is: The page generate in automatic one template every time u click one voice in menu, but the name of the page is always the same. When I click "Back" for visualize post page, I cant visualize because I have only one page! My question is: How can I create a function to manage "back page" if I have always only one page? Thanks u Reply With Quote 01-07-2015, 09:48 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts I am afraid that you are giving us *WAY* too little information for us to even guess at an answer. Show your code. Or, better, show us a live URL that exhibits the problem. I am creating a page which redirects automatically depending on the date. What I've done so far is below, but how would I make it go switch to exceeded_year.htm on 25th March 2011 for example? I will also include other dates and later put this page in a header frame and controlling the frame below so its constantly open. <html> <script type="text/javascript"> <!-- var currentTime = new Date() var date = currentTime.getDate() var month = currentTime.getMonth() + 1 var year = currentTime.getFullYear() if (year > 2011 ) {window.location = "exceeded_year.htm"; } else window.location="#" //--> </script> </html> Hi, i can't get my new logo to work in IE, it's working fine in Chrome and FireFox, it must be a JavaScript problem. here it is: http://danishwebart.com/logo/logo.php And the JavaScrip: $(function() { var canvas = $("#c"); var canvasHeight; var canvasWidth; var ctx; var dt = 0.1; var pointCollection; function init() { updateCanvasDimensions(); var g = [new Point(27, 34, 0.0, 1, "#ed9d33"), new Point(26, 38, 0.0, 1, "#d44d61"), new Point(25, 41, 0.0, 1, "#4f7af2"), new Point(22, 44, 0.0, 1, "#ef9a1e"), new Point(18, 46, 0.0, 2, "#4976f3"), new Point(12, 44, 0.0, 2.5, "#269230"), new Point(7, 41, 0.0, 2, "#1f9e2c"), new Point(5, 37, 0.0, 1, "#36b641"), new Point(4, 33, 0.0, 1, "#2e5def"), new Point(4, 29, 0.0, 1, "#d53747"), new Point(5, 25, 0.0, 1, "#eb676f"), new Point(6, 22, 0.0, 1, "#f9b125"), new Point(8, 19, 0.0, 1, "#de3646"), new Point(11, 16, 0.0, 1, "#5f8af8"), new Point(13, 14, 0.0, 1, "#efa11e"), new Point(16, 12, 0.0, 1, "#2e55e2"), new Point(19, 10, 0.0, 1, "#4167e4"), new Point(23, 8, 0.0, 1.5, "#4869e3"), new Point(28, 6, 0.0, 2, "#10a11d"), new Point(33, 5, 0.0, 2, "#cf4055"), new Point(38, 5, 0.0, 2, "#cd4359"), new Point(44, 6, 0.0, 3, "#ca273c"), new Point(51, 8, 0.0, 3, "#2650e1"), new Point(57, 11, 0.0, 3, "#4a7bf9"), new Point(63, 16, 0.0, 3.5, "#f47875"), new Point(68, 23, 0.0, 4, "#f36764"), new Point(71, 31, 0.0, 3.5, "#1d4eeb"), new Point(72, 38, 0.0, 3, "#698bf1"), new Point(72, 44, 0.0, 2.5, "#fac652"), new Point(72, 49, 0.0, 2, "#ee5257"), new Point(71, 54, 0.0, 2, "#5681f5"), new Point(70, 59, 0.0, 2, "#f8c247"), new Point(68, 64, 0.0, 2, "#4577f6"), new Point(65, 68, 0.0, 2, "#f7b326"), new Point(62, 72, 0.0, 2, "#facb5e"), new Point(59, 75, 0.0, 2, "#e02e3d"), new Point(55, 77, 0.0, 2, "#f16d6f"), new Point(53, 78, 0.0, 2.5, "#507bf2"), new Point(47, 79, 0.0, 3, "#5683f7"), new Point(40, 77, 0.0, 3.5, "#3158e2"), new Point(33, 74, 0.0, 3.5, "#f0696c"), new Point(27, 73, 0.0, 2.5, "#3769f6"), new Point(22, 73, 0.0, 2, "#6084ef"), new Point(19, 76, 0.0, 1.5, "#2a5cf4"), new Point(17, 79, 0.0, 1, "#f4716e"), new Point(25, 70, 0.0, 2, "#f8c247"), new Point(29, 67, 0.0, 2, "#ec4147"), new Point(33, 64, 0.0, 2, "#4876f1"), new Point(36, 59, 0.0, 2.5, "#2552ea"), new Point(38, 53, 0.0, 3, "#4779f7"), new Point(38, 46, 0.0, 3.5, "#4b78f1"), new Point(38, 38, 0.0, 3.5, "#4b78f1"), new Point(37, 31, 0.0, 2.5, "#4b78f1"), new Point(38, 25, 0.0, 2, "#4b78f1"), new Point(40, 20, 0.0, 2, "#4b78f1"), new Point(42, 16, 0.0, 1.5, "#4b78f1"), new Point(45, 14, 0.0, 1, "#4b78f1"), new Point(48, 12, 0.0, 1, "#4b78f1"), new Point(59, 82, 0.0, 1, "#ed9d33"), new Point(62, 80, 0.0, 1.5, "#d44d61"), new Point(66, 77, 0.0, 2, "#4f7af2"), new Point(70, 73, 0.0, 2, "#4976f3"), new Point(73, 69, 0.0, 2, "#269230"), new Point(76, 65, 0.0, 2, "#1f9e2c"), new Point(79, 60, 0.0, 2, "#36b641"), new Point(80, 55, 0.0, 1.5, "#2e5def"), new Point(81, 65, 0.0, 2.5, "#eb676f"), new Point(83, 71, 0.0, 3, "#f9b125"), new Point(84, 77, 0.0, 2.5, "#de3646"), new Point(82, 82, 0.0, 2, "#de3646"), new Point(88, 74, 0.0, 1.5, "#efa11e"), new Point(90, 70, 0.0, 1.5, "#2e55e2"), new Point(92, 66, 0.0, 1.5, "#4869e3"), new Point(93, 62, 0.0, 1.5, "#4869e3"), new Point(95, 53, 0.0, 1, "#10a11d"), new Point(95, 57, 0.0, 2, "#cf4055"), new Point(97, 62, 0.0, 2.5, "#cd4359"), new Point(100, 68, 0.0, 3, "#ca273c"), new Point(102, 74, 0.0, 2.5, "#2650e1"), new Point(101, 80, 0.0, 2, "#4a7bf9"), new Point(105, 78, 0.0, 1, "#f36764"), new Point(107, 75, 0.0, 1, "#1d4eeb"), new Point(109, 72, 0.0, 1, "#698bf1"), new Point(110, 69, 0.0, 1, "#fac652"), new Point(111, 66, 0.0, 1, "#ee5257"), new Point(112, 63, 0.0, 1, "#5681f5"), new Point(112, 60, 0.0, 1.5, "#f8c247"), new Point(112, 56, 0.0, 1.5, "#4577f6"), new Point(110, 52, 0.0, 2, "#f7b326"), new Point(107, 48, 0.0, 2.5, "#facb5e"), new Point(102, 45, 0.0, 2.5, "#e02e3d"), new Point(97, 43, 0.0, 2, "#f16d6f"), new Point(110, 83, 0.0, 1, "#507bf2"), new Point(112, 80, 0.0, 1, "#5683f7"), new Point(114, 77, 0.0, 1.5, "#3158e2"), new Point(116, 73, 0.0, 1.5, "#f0696c"), new Point(118, 69, 0.0, 1.5, "#3769f6"), new Point(119, 65, 0.0, 1.5, "#6084ef"), new Point(119, 61, 0.0, 1.5, "#2a5cf4"), new Point(119, 57, 0.0, 1.5, "#f4716e"), new Point(118, 53, 0.0, 1.5, "#f8c247"), new Point(116, 50, 0.0, 1, "#ec4147"), new Point(120, 51, 0.0, 1, "#4876f1"), new Point(123, 53, 0.0, 1, "#2552ea"), new Point(126, 55, 0.0, 1, "#4779f7"), new Point(129, 58, 0.0, 1.5, "#4b78f1"), new Point(132, 61, 0.0, 1.5, "#4b78f1"), new Point(135, 65, 0.0, 1.5, "#4b78f1"), new Point(138, 69, 0.0, 1.5, "#4b78f1"), new Point(140, 73, 0.0, 2, "#4b78f1"), new Point(142, 78, 0.0, 2, "#4b78f1"), new Point(143, 83, 0.0, 2, "#4b78f1"), new Point(121, 70, 0.0, 1, "#4b78f1"), new Point(124, 71, 0.0, 1, "#4b78f1"), new Point(127, 71, 0.0, 1, "#4b78f1"), new Point(130, 71, 0.0, 1.5, "#4b78f1"), new Point(134, 70, 0.0, 1.5, "#4b78f1"), new Point(142, 68, 0.0, 1.5, "#4b78f1"), new Point(146, 68, 0.0, 1, "#4b78f1"), new Point(149, 69, 0.0, 1, "#4b78f1")]; gLength = g.length; for (var i = 0; i < gLength; i++) { g[i].curPos.x = (canvasWidth/2 - 0) + g[i].curPos.x; g[i].curPos.y = (canvasHeight/2 - 0) + g[i].curPos.y; g[i].originalPos.x = (canvasWidth/2 - 0) + g[i].originalPos.x; g[i].originalPos.y = (canvasHeight/2 - 0) + g[i].originalPos.y; }; pointCollection = new PointCollection(); pointCollection.points = g; initEventListeners(); timeout(); }; function initEventListeners() { $(window).bind('resize', updateCanvasDimensions).bind('mousemove', onMove); canvas.get(0).ontouchmove = function(e) { e.preventDefault(); onTouchMove(e); }; canvas.get(0).ontouchstart = function(e) { e.preventDefault(); }; }; function updateCanvasDimensions() { canvas.attr({height: $(window).height(), width: $(window).width()}); canvasWidth = canvas.width(); canvasHeight = canvas.height(); draw(); }; function onMove(e) { if (pointCollection) pointCollection.mousePos.set(e.pageX, e.pageY); }; function onTouchMove(e) { if (pointCollection) pointCollection.mousePos.set(e.targetTouches[0].pageX, e.targetTouches[0].pageY); }; function timeout() { draw(); update(); setTimeout(function() { timeout() }, 30); }; function draw() { var tmpCanvas = canvas.get(0); if (tmpCanvas.getContext == null) { return; }; ctx = tmpCanvas.getContext('2d'); ctx.clearRect(0, 0, canvasWidth, canvasHeight); if (pointCollection) pointCollection.draw(); }; function update() { if (pointCollection) pointCollection.update(); }; function Vector(x, y, z) { this.x = x; this.y = y; this.z = z; this.addX = function(x) { this.x += x; }; this.addY = function(y) { this.y += y; }; this.addZ = function(z) { this.z += z; }; this.set = function(x, y, z) { this.x = x; this.y = y; this.z = z; }; }; function PointCollection() { this.mousePos = new Vector(0, 0); this.points = new Array(); this.newPoint = function(x, y, z) { var point = new Point(x, y, z); this.points.push(point); return point; }; this.update = function() { var pointsLength = this.points.length; for (var i = 0; i < pointsLength; i++) { var point = this.points[i]; if (point == null) continue; var dx = this.mousePos.x - point.curPos.x; var dy = this.mousePos.y - point.curPos.y; var dd = (dx * dx) + (dy * dy); var d = Math.sqrt(dd); if (d < 80) { point.targetPos.x = (this.mousePos.x < point.curPos.x) ? point.curPos.x - dx : point.curPos.x - dx; point.targetPos.y = (this.mousePos.y < point.curPos.y) ? point.curPos.y - dy : point.curPos.y - dy; } else { point.targetPos.x = point.originalPos.x; point.targetPos.y = point.originalPos.y; }; point.update(); }; }; this.draw = function() { var pointsLength = this.points.length; for (var i = 0; i < pointsLength; i++) { var point = this.points[i]; if (point == null) continue; point.draw(); }; }; }; function Point(x, y, z, size, colour) { this.colour = colour; this.curPos = new Vector(x, y, z); this.friction = 0.8; this.originalPos = new Vector(x, y, z); this.radius = size; this.size = size; this.springStrength = 0.1; this.targetPos = new Vector(x, y, z); this.velocity = new Vector(0.0, 0.0, 0.0); this.update = function() { var dx = this.targetPos.x - this.curPos.x; var ax = dx * this.springStrength; this.velocity.x += ax; this.velocity.x *= this.friction; this.curPos.x += this.velocity.x; var dy = this.targetPos.y - this.curPos.y; var ay = dy * this.springStrength; this.velocity.y += ay; this.velocity.y *= this.friction; this.curPos.y += this.velocity.y; var dox = this.originalPos.x - this.curPos.x; var doy = this.originalPos.y - this.curPos.y; var dd = (dox * dox) + (doy * doy); var d = Math.sqrt(dd); this.targetPos.z = d/100 + 1; var dz = this.targetPos.z - this.curPos.z; var az = dz * this.springStrength; this.velocity.z += az; this.velocity.z *= this.friction; this.curPos.z += this.velocity.z; this.radius = this.size*this.curPos.z; if (this.radius < 1) this.radius = 1; }; this.draw = function() { ctx.fillStyle = this.colour; ctx.beginPath(); ctx.arc(this.curPos.x, this.curPos.y, this.radius, 0, Math.PI*2, true); ctx.fill(); }; }; init(); }); Hi, so I thought I could mash two bits of code together like this: Code: <div><label for="or">From:</label> <select name="or" style="width:200px; float: right" id="or" onchange="populate(this)"> <option value="Choose">Select your starting point</option> <option value="Guatemala">Guatemala City</option> <option value="Xela">Quetzaltenango</option> <option value="Antigua">Antigua</option> <option value="Rio Dulce">Rio Dulce</option> <option value="Coban">Coban</option> </select></div> <div> <label for="de">To:</label> <select name="de" style="width:200px; float: right" id="de"></select> </div> <div> <br> <input type="button" onclick="searchLocations()" value="Show route" /> </div> </div> </div> </div> <script type="text/javascript"> if (GBrowserIsCompatible()) { var gpolylines = []; function populate(o) { d=document.getElementById('de'); if(!d){return;} var mitems=new Array(); mitems['Choose']=['']; mitems['Guatemala']=['Select Destination','Antigua','El Rancho junction','San Pedro La Laguna','Panajachel','Coban','Rio Hondo','Chiquimula','Esquipulas','Copan Ruinas (Honduras)','La Ruidosa junction','Rio Dulce','Flores (via Rio Dulce)','Puerto Barrios','Flores (via Coban)','Quetzaltenango']; mitems['Xela']=['Select Destination','Guatemala City','Antigua','Chichicastenango','Huehuetenango','Panajachel','San Pedro La Laguna']; mitems['Antigua']=['Select Destination','Guatemala City','Quetzaltenango','Escuintla','Monterrico','San Pedro la Laguna','Panajachel','Chichicastenango']; mitems['Rio Dulce']=['Select Destination','Guatemala City','Flores','Lanquin','Coban','Puerto Barrios']; mitems['Coban']=['Select Destination','Lanquin','Rio Dulce','Laguna Lachua NP','Flores']; d.options.length=0; cur=mitems[o.options[o.selectedIndex].value]; if(!cur){return;} d.options.length=cur.length; for(var i=0;i<cur.length;i++) { d.options[i].text=cur[i]; d.options[i].value=cur[i]; } } function searchLocations() { var found = false; var from = document.getElementById('or').value; var to = document.getElementById('de').value; for (var a = 0; a < gpolylines.length; a++) { if (gpolylines[a].myname.toLowerCase() == to.toLowerCase() && gpolylines[a].mycategory.toLowerCase() == from.toLowerCase()) { found = true; gpolylines[a].show(); } } if ( ! found ) alert("No matches found. Please check your spelling or refine your search."); } the first bit, which populates the select boxes works fine, as you can see here but the second bit (the searchLocations function) is giving me a bit more trouble. What it's supposed to be doing is saying that if there's a polyline whose category xml attribute matches the text from the 1st select box AND whose name attribute matches the 2nd select box, it should be shown. The methods have worked in the past, there are no errors reported - the only problem is I get the alert regardless of which option I am selecting. I suspect that the problem is in the if (gpolylines[a].myname.toLowerCase() == to.toLowerCase() && gpolylines[a].mycategory.toLowerCase() == from.toLowerCase()) line, as it's the only one that I really came up with on my own... or can I not get the "or" and "de" elements in that way? Or is it something else entirely? thanks in advance for any suggestions... I'm working with this form which has js calendar. unfortunately, I can't get the calendar to work onclick. It produces the following error: Code: Uncaught SyntaxError: Unexpected token can't make out the error. Not sure if this is related to another onclick function. Here is the actual code: Code: <form name='PaymentForm' onsubmit='return ValidatePaymentForm();' action='updatebalancedue.php' method='post'> <input type=\"hidden\" name=\"edit_sel_id\" value=\"$sel_id\"> <div id=\'pmt_header\'><center><table class=\'tablestyle2\' width=90% cellpadding=2 cellspacing=0> <tr valign='top'> <td style=\'border:1px solid #cccccc;\' width=\"28%\" align=\"justify\"> <table class=\'tablestyle_inner\' width=\"170\"> <tr> </td> </tr> <tr><td bgcolor='#000000'><font color='#FFFFFF' class='label'>Payment Received Date:</td> </tr> </table> <input type='text' value='$date' readonly name='theDate' size='11'><input type='button' class='NonPrintable' value='Calendar' onclick='displayCalendar(this.form.theDate,'yyyy/mm/dd',this)'> </td> <td style='border:1px solid #cccccc;' width=\"35%\"> <table class='tablestyle_inner' width='607'> <tr><td valign='top'class='label' width='110'>Date of Invoice</td> <td width='196'><span id='_PayType_sel'><input name='$date_on_invoice' value='$date_on_invoice' disabled='true' style='float: left' valign='top'></td> <td valign='top' width='106'>Client ID: </td><td valign='top'> <input name='$clientID' value='$clientID' disabled='true' style='float: left'></span></td> <tr><td class='label' width='110'>First Name:</td><td width='196'><input type='text' size='22' maxlength='50' value='$firstname' disabled='true' style='float: left'></td><td valign='top'>Last Name:</td><td valign='top'><input type='text' size='22' maxlength='50' value='$lastname' disabled='true' name='T1' style='float: left'></td> </tr> </table> </td> <td style='border:1px solid #cccccc;' width='35%' align='right'> <table class='tablestyle_inner'> <tr><td bgcolor='#000000'><font color='#FFFFFF' class='label' align='left'>New Bal.:</td></tr><tr><td><input name='dollarsymbol3' size='1' readonly style='border:0px;' value='$'><input id='amount' name='newbalance' readonly style='color: #EE0000' size='8' maxlength='16' value='0.00'> <!--<input type='text' name='newbalance' disabled='true' size='16' maxlength=\"18\" value='$0.00'--></td> </tr> </table> <td style='border:1px solid #cccccc;' width='35%' align='right'> <table class='tablestyle_inner'> <tr><td bgcolor='#000000'><font color='#FFFFFF' class='label' align=\"left\">Payment Reference:</td></tr><tr><td><input type='text' name='paymentref' size='16' maxlength='18' value='$RNO'</td> </tr> </table> </table></center> <br></div> <div id='items_table'><center> <table class='tablestyle' colspan=7 width='89%' cellpadding=2 cellspacing=0> <tr> <td style='border:1px solid #cccccc;' width=' 15%' class='tableheader' bgcolor='#000000'><font color='#FFFFFF'> Invoice Number</td> <td align='center' style='border: 1px solid #cccccc;' width=' 15%' class='tableheader' bgcolor='#000000'><font color='#FFFFFF'>Service Description</td> <td style='border: 1px solid #cccccc;' width=' 15%' class='tableheader' bgcolor='#000000'><font color='#FFFFFF'>Balance Due</td> <td style='border: 1px solid #cccccc;' width=' 15%' class='tableheader' bgcolor='#000000'><font color='#FFFFFF'>Payment</td> <td style='border: 1px solid #cccccc;' width=' 15%' style='border:1px solid #cccccc;' width=' 15%'class='tableheader' bgcolor='#000000'><font color='#FFFFFF'>Payment Type</td> </tr> <tr> <td valign='top' style='border-left: 0px solid #cccccc;' width=' 15%'><input type='text' name='$invoicenum' disabled='true' size='12' maxlength='10' value='$invoicenum' class='combo3' rel='code_id' title=''> </td><td valign='top' style='border-right: 0px solid #cccccc;' width=' 15%' ><span id='_code_id_sel'> <!-- the line below serves to auto adjust the textarea box in accordance with the box's content. The class allows the box to expend to 1000 this works with two files jquery.textarea-expander.js and jquery-1.3.2.min.js --> <textarea name='mytextarea' id='mytextarea' rows='3' cols='60' disabled='true'class='expand10-100'>$servicedesc</textarea> <!--<textarea name='servicedesc' cols='30' rows='2' disabled='true' >$servicedesc</textarea></span>--> </td> <input type=\"hidden\" name=\"dimension2_id\" value=\"0\"> <td valign='top' style='border-left: 0px solid #cccccc;' width=' 15%' align='left'> <input name='dollarsymbol2' size='1' readonly style='border:0px;' value='$'><input id='amount' name='balance' size='12' disabled='true' value='$new_bal' onChange='updatesum()'> <!--<input class='amount' type=\"text\" name='balance' disabled='true' size=\"15\" maxlength=\"15\" dec=\"2\" value='$Balancedue'>--></td> <td valign='top' style='border-left: 0px solid #cccccc;' width=' 15%' align='left'> <input name='dollarsymbol1' size='1' readonly style='border:0px;' value='$'><input id='amount' name='paymentamount' size='12' style='color: #71C671' value='0.00' onChange='updatesum()'></td> <td valign='top' style='border-left: 0px solid #cccccc;' width=' 15%' ><span<select autocomplete='on' name='paymenttype' ><OPTION>Select One <OPTION>Cash <OPTION>Check <OPTION>Visa <OPTION>Master Card <OPTION>AMEX <OPTION>Discover <OPTION>Other </select></span></td> </tr> </table></center> </div> <br><table align='center'><tr><td >Memo</td><td><textarea STYLE='display:inline' name='memo' cols='50' rows='3'></textarea></td> </tr> </table> <br><br><center><input type='button' class='NonPrintable' value='Select Another Record' ONCLICK='history.go(-1)'> <input type='submit' name='submit' class='NonPrintable' value='Record Payment'> <input type='button' class='NonPrintable' onClick='window.print()' value='Print' /> </center> </p> </form>"; I'm using the form within a php code. This is my script section: Code: <script type="text/javascript" src="../../js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="../../js/jquery.textarea-expander.js"></script> <script> function ValidatePaymentForm() { var paymentamount = document.PaymentForm.paymentamount; var paymenttype = document.PaymentForm.paymenttype; if (paymentamount.value == "0.00") { window.alert("Sorry, no Payment Amount is indicated!"); paymentamount.focus(); return false; } if (paymenttype.value == "Select One") { window.alert("Indicate form of payment!"); paymenttype.focus(); return false; } return true; } </script> <!--script for calendar begins--> <link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK> <SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script> <!--script for calendar ends--> The calendar code is highlighted in red. any assistance is appreciated! Hi, I have html variable as below: html += "<div class='quickSearchResultDivUnselected' style='width:" + divWidh + "px;max-width:" + divWidh + "px'><a href='#' OnClick='javascript:test('" + title + "')>" + title + "</a></div>"; The problem is with OnClick='javascript:test('" + title + "')>". How to make this link as <a OnClick='javascript:test("VALUE")'></a>, because now as result it looks like this and it doesn't work: <a OnClick='javascript:test('value')'></a>; So the problem is with ' and ". How to make it correctly in this long line of html variable ? Please help. Ok, I today installed IE9 and now my site has lost the main menu. The problem lies in my application.js file code below, any ideas on what may have caused this? When debugging in VS2010 it throws therror at the line prettyPrint(); with the error prettyPrint is underfined? I havent changed anything other than move browser from ie8 to ie9 Code: var submitting = false; $(function(){ $.ajaxSetup({ type: 'POST', dataType: 'json', timeout: 7500, error: function(x, s, t) { //alert(error_message); }, complete: function(){submitting = false;} }); }); $(window).load(function () { // Prittify prettyPrint(); }); /** * toggleLink */ (function($){ $.fn.toggleLink =function (options) { var options = $.extend({ visible: 'view source', invisible: 'hide source' }, options); return this.each(function(i, e) { $(e).click(function (event) { event.preventDefault(); var $this = $(this); var obj = $('#' + $this.attr('rel')); if (obj.is(':visible')) { obj.hide(); $this.text(options.visible); } else { obj.show(); $this.text(options.invisible); } }); }); } })(jQuery); /** * toggleLinkAll */ (function($){ $.fn.toggleLinkAll =function (options) { var options = $.extend({ visibleAll: 'view all sources', invisibleAll: 'hide all sources', visible: 'view source', invisible: 'hide source', children: '#things a.showSource' }, options); return this.each(function(i, e) { $(e).click(function (event) { event.preventDefault(); var $this = $(this); var v = $this.data('visible'); var visible = (typeof v == 'undefined' || v == true); $(options.children).each(function () { var $t = $(this); var id = $t.text((visible) ? options.invisible: options.visible).attr('rel'); if (visible) { $('#' + id).show(); } else { $('#' + id).hide(); } }); if (visible) { $this.text(options.invisibleAll).data('visible', false); } else { $this.text(options.visibleAll).data('visible', true); } }); }); } })(jQuery); /** * paginate */ (function($){ $.fn.paginate =function (options) { var options = $.extend({ type: 'GET', dataType: 'html', timeout: 7000, success: null }, options); return this.each(function(i, e) { $(e).click(function() { var $this = $(this); $this.parent('div') .html('<img src="/images/loading.gif" class="valign_middle"/> ' + '<span class="green">loading...</span>'); options.url = $this.attr('href'); $.ajax(options); return false; }); }); } })(jQuery); /** * Destroyer */ (function($){ $.fn.destroyer =function (options) { var options = $.extend({ progressMessage: 'deleting...', completeMessage: 'deleted!', errorMessage: 'Sorry, an error occured.' }, options); var destroy = function() { var $this = $(this); var token = $this.attr('rel').split('_'); var type = token[0]; var key = token[1]; var msg = 'Sure you want to delete this ' + type + '? There is NO undo!'; if (!window.confirm(msg)) return false; var parent = $(this.parentNode); var container = $('#' + type + '_' + key); $.ajax({ type: 'POST', url: '/' + type + '/' + key + '/delete/', beforeSend: function(){ parent.html(options.progressMessage + '...'); }, dataType: 'json', data: {_method: 'delete'}, timeodut: 6000, success: function(obj){ if(obj.error){alert(options.errorMessage);} else if(obj.success){ if (container.length > 0) { container.hide(); } else if (obj.redirect) { window.location = obj.redirect; } else {window.location = '/';} } else { alert(options.errorMessage); } }, error: function () { alert(options.errorMessage); } }); return false; } return this.each(function(i, e) { $(e).click(destroy); }); } })(jQuery); I really don't even know if I'm posting this question in the right section. I am using javascript to make a drop-down menu for a website. I really don't have any experience with javascript. The problem I'm having is that when I go to the page, the drop down menu is already dropped down. If you then hover over it, it pulls up and then hover over it again and it drops back down. It works fine after the initial glitch. Didn't know if anyone had run into this problem or if I'm just being stupid, here is the code that I'm using. Thanks in advance for any help. <a href="/mainpage.html" onMouseOver="show()" onMouseOut="hide()" ><img src="pic.png" border="0" width="90" height="24"></a></br> <div id="div1"><a href="/notherpage.html" onMouseOver="show()" onMouseOut="hide()" ><img src="pic2.png"><br><a href="/notherpage2.html" onMouseOver="show()" onMouseOut="hide()" ><img src="pic3.png"><br><a href="/lastpage.html" onMouseOver="show()" onMouseOut="hide()" ><img src="pic4.png"></div> <script type="text/javascript"> function show(){ document.getElementById("div1").style.display="block"; } function hide(){ document.getElementById("div1").style.display="none"; } </script> |