JavaScript - Complete Newbie Asks: Is There A Generic Name For The Subject Of The Event ??
I am trying to trigger one custom function or another, depending on whether a radio button is checked or not.
How can this be done? (I was hoping that "self" would be the ticket, but I think I was barking up the wrong tree.) Code: function toggleFieldsetByRadio(element){ if(SELF.checked){ enable(element); }else{ disable(element); } } How should I do this? I am hoping to use this function with an onchange event. ~ Mo Similar TutorialsI need javascript event calendar sourcecode with highlighting of colors when dates selecting from datepicker of DHTMLgoodies calendar I'm building a website to catalog a history of college football uniforms, and having something like this on several of the pages would be extremely helpful. I've been told that making it in Javascript instead of Flash would be better for my website. I've also been told that it should be relatively easy to write the code for it. In short, I want to be able to take the parts of this image and allow viewers of the site to be able to switch between parts to mix and match. There are quite a few teams with six or more possible uniform combinations, so I'd like to be able to do this for the site. This would probably be a good way to get my start on learning at least some Javascript basics, so would anyone be willing to help me put this together? First of all, thanks for looking! I'm doing this nonprofit site for a students club in my college, and it needs an event calendar. I just have a bit of touch on javascript, and the only way this is going to be done in is javascript so I'm stuck with it. I took one of my assignments and modded it to the requirements of them. 1. A 6 month calendar. problem - I have to get thismonth, check whether its <July,then display Jan to June. Else July to December.(A semester calendar) figured it out. 2.Want to highlight a specific date, and place a link in it, so when somebody click the date, say a textarea in a form, displays the event details. problem - Have no idea on how to do it. Any help on this is warmly welcome ! My calendar.htm file Code: <html> <head> <title>Calendar</title> <link href="calendar.css" rel="stylesheet" type="text/css" /> <script src="calendar.js" type="text/javascript"></script> </head> <body> <div id="main"> <script type="text/javascript"> yearly(); </script> </div> </body> </html> My css file Code: #yearly_table {border: 1px solid black; font-size: 8pt; width: 500px; font-family: Arial, Helvetica, sans-serif; background-color: white} #yearly_title {color: white; background-color: rgb(223,29,29); letter-spacing: 6; font-size: 12pt} .yearly_months {vertical-align: top; border: solid 1px black} .monthly_table {font-size: 8pt; width: 100%; background-color: white} .monthly_title {background-color: rgb(223,29,29); color: white; letter-spacing: 4} .monthly_weekdays {border-bottom: 1px solid black} .monthly_dates {text-align: right} #today {font-weight: bold; color: rgb(223,29,29); background-color:#999; border: 1px solid black; text-align: center} My .js file Code: tes the month name in the monthly table writeDayNames() Writes the weekday title rows in the calendar table daysInMonth(calendarDay) Returns the number of days in the month from calendarDay writeMonthDays(calendarDay, currentTime) Writes the daily rows in the monthly table, highlighting the date specified in the currentTime parameter. writeDay(weekDay, dayCount, calendarDay, currentTime) Write the opening and close table row tags and the table cell tag for an individual day in the calendar. */ function yearly(calDate) { if (calDate == null) calendarDay=new Date(); else calendarDay = new Date(calDate); var currentTime = calendarDay.getTime(); var thisYear = calendarDay.getFullYear(); document.write("<table id='yearly_table'>"); document.write("<tr><th id='yearly_title' colspan='4'>"+thisYear+"</th></tr>"); var semMonth=calendarDay.getMonth(); var monthNum; if (semMonth <6) { monthNum = -1 } else { monthNum = 5; } for (var i=1; i<=2; i++) { document.write("<tr>"); for (var j=1; j<=3; j++) { monthNum++; calendarDay.setDate(1); calendarDay.setMonth(monthNum); writeMonthCell(calendarDay, currentTime); } document.write("</tr>"); } document.write("</table>"); } function writeMonthCell(calendarDay, currentTime) { document.write("<td class='yearly_months'>"); writeMonth(calendarDay, currentTime); document.write("</td>"); } function writeMonth(calendarDay, currentTime) { document.write("<table class='monthly_table'>"); writeMonthTitle(calendarDay); writeDayNames() writeMonthDays(calendarDay, currentTime); document.write("</table>"); } function writeMonthTitle(calendarDay) { var monthName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var thisMonth=calendarDay.getMonth(); document.write("<tr>"); document.write("<th class='monthly_title' colspan='7'>"); document.write(monthName[thisMonth]); document.write("</th>"); document.write("</tr>"); } function writeDayNames() { var dayName = new Array("S", "M", "T", "W", "R", "F", "S"); document.write("<tr>"); for (var i=0;i<dayName.length;i++) { document.write("<th class='monthly_weekdays'>"+dayName[i]+"</th>"); } document.write("</tr>"); } function daysInMonth(calendarDay) { var thisYear = calendarDay.getFullYear(); var thisMonth = calendarDay.getMonth(); var dayCount = new Array(31,28,31,30,31,30,31,31,30,31,30,31); if ((thisYear % 4 == 0)&&((thisYear % 100 !=0) || (thisYear % 400 == 0))) { dayCount[1] = 29; } return dayCount[thisMonth]; } function writeMonthDays(calendarDay, currentTime) { var weekDay = calendarDay.getDay(); document.write("<tr>"); for (var i=0; i < weekDay; i++) { document.write("<td></td>"); } var totalDays = daysInMonth(calendarDay); for (var dayCount=1; dayCount<=totalDays; dayCount++) { calendarDay.setDate(dayCount); weekDay = calendarDay.getDay(); writeDay(weekDay, dayCount, calendarDay, currentTime); } document.write("</tr>"); } function writeDay(weekDay, dayCount, calendarDay, currentTime) { if (weekDay == 0) document.write("<tr>"); if (calendarDay.getTime() == currentTime) { document.write("<td class='monthly_dates' id='today'>"+dayCount+"</td>"); } else { document.write("<td class='monthly_dates'>"+dayCount+"</td>"); } if (weekDay == 6) document.write("</tr>"); } Write a program named Median.java that asks the user for three integers and outputs the median. I have to do this using if else statements. It seems really easy, but I can't figure it out. Help! Here's my code: Code: import java.util.*; public class Median { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.println("Please enter number 1"); int max = console.nextInt(); int min = max; int median = min; for (int i=2; i <= 3; i++) { System.out.println("Please enter number "+i); int enteredNumber = console.nextInt(); if (enteredNumber > max) { max = enteredNumber; } else { enteredNumber = median; } if (enteredNumber < min) { min = enteredNumber; } else { enteredNumber = median; } } System.out.println("The median is: "+median); } } When I run this it just gives me back the first number I entered. I am wondering if its possible to execute a JavaScript script as soon as the page is loaded? Perhaps a generic execution? I tried this, but it didn't work: Code: <SCRIPT type="text/javascript"> if (document.forms["form"]["quantitym"].value > '.$row['sizem'].') { alert ("The quantity for product $row['id'] is no longer available."); } </SCRIPT> <FORM action="updatecart.html" method="post" name="form"> <DIV> <B>Medium:</B> <INPUT name="quantitym" value="'.$content['sizem'].'"> </DIV> </FORM> This is for my shopping cart system. The idea is, the customer might have 4 items in his cart, but whilst he was shopping, someone might of bought the same item, result in only 3 being available, but his cart still says 4. My solution to this is to make a script run through out his shopping when ever the cart items are listed and just prior payment execution, if the quantity he wants is no longer available, he will be alerted. $row['sizem'] is PHP drawing how many items there are from my stock database. If the value of the INPUT exceeds this availability, JavaScript shall alert. Does anyone know why it isn't alerting? Basically i dont understand the concept of the timing for animation. I seen some code samples and they seem to subtract two different times from eachother :S you can tell im confused. and also about calculating frames...heres a quote explaining how frames work but stupid me all of a sudden dont seem to understand english anymore Quote: After that, we need to calculate the total number of frames we are going to animate. If a time of 0 or less then 0 is given, then we are just going to have 1 frame. Otherwise, we divide the time by 40. This is just an arbitrary value that means each frame will last 40 milliseconds (which comes out to 25 frames per second). It doesn't matter if the number of frames comes out to a fraction - we are just going to be using that value to calculate the correct amount of movement per frame. thank you Hi forum, I am trying to attach an event to a dynamically produced button, and then use stopPropagation and preventDefault. Code: function chapter12_nodeOne() { //create an element var element = document.createElement('input'); //set some attributes element.setAttribute('type', 'button'); element.setAttribute('value', 'submit'); element.setAttribute('id', 'myBtn'); //appendd the element into a DIV document.getElementById('myDiv').appendChild(element); //uses EventUtil to attach an event listener EventUtil.addHandler(element, 'click', function() { alert('event attached'); }); var flag = confirm('prevent default behavior of button?'); if (flag) { var el = document.getElementById('myBtn');/////////////////////////(1) var ev = el.onclick; } } var EventUtil = { addHandler: function(element, type, handler) { //check if the element and the browser support DOM Level 2 event attachment //if the user is not browsing with IE if (element.addEventListener) { element.addEventListener(type, handler, false); } //if user is browsing with IE else if (element.attachEvent) { element.attachEvent("on" + type, handler); } //if user is using a browser that only supports DOM Level 0 event attachment else { element["on" + type] = handler; } }, removeHandler: function(element, type, handler) { //check if the element and the browser support DOM Level 2 event attachment //if the user is not browsing with IE if (element.removeEventListener) { element.removeEventListener(type, handler, false); } //if user is browsing with IE else if (element.detachEvent) { element.detachEvent("on" + type, handler); } //if user is using a browser that only supports DOM Level 0 event attachment else { element["on" + type] = null; } } }; But when debugging I see under el on the line marked with (1) that the onclick event is null. What am I doing wrong?! PS:the event is attached, when I click on the button I get an alert message Hi, I am setting up an email form & i would like the subject field to hold multiple values, the forrm will be something like this: Name:Mr A Date: 01/01/01 Reason:Football I want the form to send an email without opening an email client & I would like the subject field to look like this: Subject: Mr A, 01/01/01, Football or Subject Mr A - 01/01/01 - Football Can anyone tell me if this is possible, if if is can you please point me in the right direction. Thanks is it possible to capture the control.event or element.event that was fired to invoke the onbeforeunload event. for example, if a button is clicked and it causes the onbeforeunload event to fire can i determine which button was clicked. thanks Hi guys, I'm looking for a way i can set some of the mailto form data - mainly the full name and holiday start date into the subject line of the email. this is the code for my form: Code: <html> <head> <body bgcolor="#DCDCDC"> <font size="3" face="tahoma" color="#000000"> <form action="MAILTO:email@email.co.uk?subject=Holiday Request" method="post" enctype="text/plain" font-weight: bold; size="10" maxlength="30"> <u><b>Holiday Request Form</b></u> <br /><br /> First Name: <input type="text" name="first-name" /> <br /><br /> Last Name: <input type="text" name="last-name" /> <br /><br /> Holiday Type: <select name = "Holiday Type"> <option value="new holiday">New Holiday</option> <option value="amend holiday">Amend Holiday</option> <option value="delete holiday">Delete Holiday</option> </select> <br /><br /> Start Holiday: <select name = "Start Day"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> / <select name = "Start Month"> <option value="january">Jan</option> <option value="febuary">Feb</option> <option value="march">Mar</option> <option value="april">Apr</option> <option value="may">May</option> <option value="june">Jun</option> <option value="july">Jul</option> <option value="august">Aug</option> <option value="september">Sep</option> <option value="october">Oct</option> <option value="november">Nov</option> <option value="december">Dec</option> </select> / <select name = "Start Year"> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> </select> <br /><br /> End Holiday: <select name "End Day"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> / <select name = "End Month"> <option value="january">Jan</option> <option value="febuary">Feb</option> <option value="march">Mar</option> <option value="april">Apr</option> <option value="may">May</option> <option value="june">Jun</option> <option value="july">Jul</option> <option value="august">Aug</option> <option value="september">Sep</option> <option value="october">Oct</option> <option value="november">Nov</option> <option value="december">Dec</option> </select> / <select name = "End Year"> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> </select> <br /><br /> Total Hours Required: <input type="text" name="total-hours" size="6"/> <br /><br /> Notes Box: <br /> <textarea name="Additional Info" rows="5" cols="40"> Enter here any additional information that may be required. </textarea> <br /><br /> Half Day Tickbox: <input type="checkbox" name="half-day" value="half-day"/> <br /><br /> Start Shift: <select name = "Start Shift Hours"> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> </select> : <select name = "Start Shift Minutes"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> <br /><br /> End Shift: <select name = "End Shift Hours"> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> </select> : <select name = "End Shift Minutes"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> <br /><br /> Lunch Start: <select name = "Lunch Start Hours"> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> </select> : <select name = "Lunch Start Minutes"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> <br /><br /> Lunch End: <select name = "Lunch End Hours"> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> </select> : <select name = "Lunch End Minutes"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> <br /><br /> Holiday Start Time: <select name = "Holiday Start Hours"> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> </select> : <select name = "Holiday Start Minutes"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> <br /><br /> Holiday End Time: <select name = "Holiday End Hours"> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> </select> : <select name = "Holiday End Minutes"> <option value="00">00</option> <option value="15">15</option> <option value="30">30</option> <option value="45">45</option> </select> <br /><br /> <input type="submit" value="Send"> </form> </font> </body> </head> </html> Any help will be appreciated. Thanks, Craig I'm looking for a simple javascript that can fill in the subject of an email message with whatever is in the title tags of the page they're on and also to include the link the the page in the body. [CODE] <a href="mailto:e@o.com?subject=&body=http://www.o.htm" title="Question"> [CODE] Thanks! I have a ondrag event handler and in that I am trying to retrieve e.ClientX but it always return 0 in Mozilla. Works fine in IE though. How can retrieve the clientX and clientY in ondrag event? http://yfrog.com/ed20392020p need 2 make those 2 pics in java n i dont even know where to start T-T, the one on the right is supoose to be like lil boat lookin things can anyone give me a place where i can learn to make a line then array it from the center? Hello, I am trying to complete a test site but adding some javascript. In short I am trying to make the main content div slide from behind the nav via some JS. http://www.squareflash.com/test/index.html First I am just trying to get the animate onClick to work. I found this practice site -- Using this I am trying to get some guidance on how to add a automatic stop function to the moveRight variable. http://www.tutorialspoint.com/cgi-bi...=javascript_45 The site is in html5, is there anything special I need to know for that? ty I have been searching for years to get ahold of a complete reference to the ECMAscript languages. I was recently watching some old videos by Douglas Crockford. He talked about the 'set' and 'get' statements. I had never heard of them before... and infact was one of the things I really missed from Delphi and have been wishing for in javascript. Even now I can't find any references that contain them. I keep having this feeling that there is so much more in the language than I know about and there is no easy way to learn it. Where is the most complete reference of the language? David This may seem a long shot, but 5 years ago I found a script that had everything (not just alpha, etc, but everything). I have looked at Jquery validation and while it is robust, many of the examples were bugged. I am no coder, and I feel like I may be torched here for wasting precious space. However, I was really hoping you all could point me in a right direction. Perhaps if not java, with something else. Paid, Donate, Free. Anything. (The only script I have on form now is just Auotab next/prev plugin for jquery) Function required: Inline on change/next type matching (confirm email/pw fields) basic formatting (numeric only, alpha with spaces, etc) Basic validation of email type expressions, etc Required fields, etc However, I would love to take it a step further Email: Checks for valid TLD Password: sctricter requirements Phone: Requires legitimate values (not just numeric); ie: 201-999, no 555, 411,611,911, etc Date of birth: Checks valid ranges of dates entered; checks min/max age requirement Possible real time database or web services checks (which would be ajax, etc im sure) custom number values (ie, for credit cards, number must be xxxx-xxxx (not 0000-1111-2222-3333 Any other possible logical info, for instance, Name not in badnames list (like Fred Flinstone, IP Freely, or other Cuss words/phrases) Yes, I know most of these would wind up as a server side reject on the submit page, where we could possibly recapture the data. However, that type of method typically lowers conversions. Yes, there is the Jquery plugin, and with knowhow, you can make it do this, however I dont have the knowhow and would rather donate/pay for something already out of the box. The use for this would be contact forms, profile forms, info requests, sales pages, Hi, I'm trying to work through a head first book on ajax and javascript. I am also trying to emplement some of the codes in a small application I had built strictly with server side code. What it does is: two input fields for user defined values. Once the user inputs the two values, they are passed to the action page, some simple math is performed on these 2 values, and then 4 different resluts are displayed back on the action page. What I wanted was of course to make this asynchronous and display the results without a page reload. So, when I reworked the book code for my own use, and try to run the application, I get an error saying my url variable is undefined. The value of the first input seems to be passed though. One thing of note to mention is the application was written in coldfusion. The form values are passed using cf. Not sure if that matters. I mean cf works well with js and ajax, but maybe my original procedure doesnt work with my js code as it is now. Here is the javascript/ajax code: PHP Code: <script type="text/javascript" language="javascript"> var request = null; try { request = new XMLHttpRequest(); } catch (trymicrosoft) { try { request = new ActiveXObject("Msxm12.XMLHTTP"); } catch (othermicrosoft) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { request = null; } } if(request == null) alert("Error creating request object!"); } function getLampVolts() { var lamp = document.getElementById("lampVoltage").value; var url = "calculatorAction.cfm?lamp = " + escape(lampVolts); request.open("GET", url, true); request.onreadystatechange = updatePage; request.send(null); } function updatePage() { if(request.readyState == 4) { if(request.status == 200) { var lumens = request.responseText; document.getElementById("lumens").value = lumens; } else alert("Error! Request Status is " + request.status); } } </script> Here is the form: Code: <form action="calculatorAction.cfm"> <table> <tr> <th>Lamp Voltage</th> <td><input name="lampVoltage" id="lampVoltage" type="text" /></td> </tr> <tr> <th>Socket Voltage</th> <td><input name="socketVoltage" id="socketVoltage" type="text" /></td> </tr> <tr> <td><input type="button" value="Submit" onClick="getLampVolts();" /></td> <td><input type="reset" value="Reset" /></td> </tr> </table> and here is my action page calculatorAction.cfm: Code: <cfparam name="bulbCalculator.cfm" type="any" default="0"> <!--- Set User Defined Values of Form ---> <cfset lampVolts = FORM.lampVoltage> <cfset actualVolts = FORM.socketVoltage> <!--- Set Constants For Calculations ---> <cfset lumens = 27500> <cfset life = 500> <cfset watts = 65> <cfset colorTemp = 3500> <!--- Perform Calculations ---> <cfset actualLumens = ((actualVolts/lampVolts)^3.4)*lumens> <cfset lumenPercent = actualLumens/lumens*100> <cfset hours = ((lampVolts/actualVolts)^13)*life> <cfset hourPercent = hours/life*100> <cfset actualWatts = ((actualVolts/lampVolts)^1.3)*watts> <cfset wattPercent = actualWatts/watts*100> <cfset temperature = ((actualVolts/lampVolts)^.42)*colorTemp> <cfset tempReduction = temperature-colorTemp> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <cfsavecontent variable="calculations"> <table> <cfoutput> <tr> <td>Lamp Rated Voltage:</td> <td>#lampVolts#</td> </tr> <tr> <td>Socket Application Voltage:</td> <td>#actualVolts#</td> </tr> <tr> <td id="lumens">Percent of Lumens Used:</td> <td>#round(lumenPercent)#%</td> </tr> <tr> <td>New Rated life in Percentages:</td> <td>#round(hourPercent)#%</td> </tr> <tr> <td>Percent of Watts Used:</td> <td>#round(wattPercent)#%</td> </tr> <tr> <td>Change in Temperatu </td> <td>#round(tempReduction)#°</td> </tr> </cfoutput> </table></cfsavecontent> </body> </html> Again, the url variable says it is undefined. But the variable "lamp" contains the form field value. Thanks for any help and tips in advance! I have used the following script to make provide matching value suggestions for any text typed in the text box and user can select any value by clicking it this works fine in firefox, crome but not in IE. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Ajax Auto Suggest</title> <!--http://www.nodstrum.com/2007/09/19/autocompleter/ --> <script type="text/javascript" src="jquery-1.2.1.pack.js"></script> <script type="text/javascript"> function lookup(inputString) { if(inputString.length == 0) { // Hide the suggestion box. $('#suggestions').hide(); } else { $.post("rpc.asp?inputString="+inputString+"", {}, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { $('#inputString').val(thisValue); boxhide(); } function boxhide() { setTimeout("$('#suggestions').hide();", 200); } </script> <style type="text/css"> body { font-family: Helvetica; font-size: 11px; color: #000; } h3 { margin: 0px; padding: 0px; } .suggestionsBox { position: relative; left: 30px; margin: 10px 0px 0px 0px; width: 200px; background-color: #212427; -moz-border-radius: 7px; -webkit-border-radius: 7px; border: 2px solid #000; color: #fff; } .suggestionList { margin: 0px; padding: 0px; } .suggestionList li { margin: 0px 0px 3px 0px; padding: 3px; cursor: pointer; } .suggestionList li:hover { background-color: #659CD8; } </style> </head> <body> <div> <form> <div> Type your county: <br /> <input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" onblur="boxhide();" /> </div> <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" /> <div class="suggestionList" id="autoSuggestionsList"> </div> </div> </form> </div> </body> </html> rpc.asp returns values matching the inputstring passed <li id='suggestedValue' onclick=""fill('Matchvalue');"">Matchvalue</li> Any help? |