JavaScript - Passing An Event To A Function... What Is Wrong With My Code?
HTML CODE BELOW (JAVASCRIPT CODE FOLLOWS);
Code: <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>Text Object value Property</title> <script type="text/javascript" src="../jsb-global.js"></script> <script type="text/javascript" src="jsb-11-02.js"></script> </head> <body> <h1>Text Object value Property</h1> <form id="UCform" action="make-uppercase.php"> <p> <input type="text" id="converter" name="converter" value="sample"> </p> </form> </body> </html> This program below switches what is entered into the text filed to caps when hitting the enter button or the tab button. Can someone explain to me why it is not working. The answer would be helpful to a newbie who's trying hard to learn the fundamentals... Code: // initialize when the page has loaded window.onload = initialize; var oInput; // (global) input field to make uppercase // apply behaviors when document has loaded function initialize() { // do this only if the browser can handle DOM methods if (document.getElementById) { // apply event handler to the button oInput = document.getElementById('converter'); if (oInput){ var event = oInput.onchange; upperMe(event); } // apply event handler to the form var oForm = document.getElementById('UCform'); if (oForm) { var event = oForm.onsubmit; upperMe(event); } } } // make the text UPPERCASE function upperMe(evt) { // consolidate event handling if (!evt) evt = window.event; // set input field value to the uppercase version of itself var sUpperCaseValue = oInput.value.toUpperCase(); oInput.value = sUpperCaseValue; // cancel default behavior (esp. form submission) // W3C DOM method (hide from IE) if (evt.preventDefault) evt.preventDefault(); // IE method return false; } Similar TutorialsHello! I'm working with nested functions and trying to pass a 'this' value to an anonymous being used in an assignment for an event listener. Here's the basics of my code: Code: <div id='abc'></div> <script type='text/javascript'> var abc = function () { this.myFunction = function() { var myObj myObj = document.createElement("input"); myObj.setAttribute("type", "button"); myObj.setAttribute("value", "Click Me"); myObj.addEventListener("click", function () { this.doDing(); }, false); document.getElementById('abc').appendChild(myObj); } this.doDing = function () { alert('ding'); } } var myInstance = new abc(); myInstance.myFunction(); </script> So, this should plop a button inside our DIV and when clicked I'd like it to run the alert-ding; unfortunately it seems to want to run the function as defined under the buttons object which doesn't work out too well. Any suggestions? Thanks! I'm having trouble passing an array into an event handler. This does not work: Code: var lightbulb = [1,1,1,0,1,0] var banana = [0,0,1,1,0,1] function changetextimage(arr){ for(var i=0;i<5;i++){ var pixel = document.getElementById("text"+i); if (arr[i]) { pixel.style.color="#000000"; } else { pixel.style.color="#FFFFFF"; } } } $('#lightbulbpicture').mouseover(changetextimage(lightbulb)); $('#bananapicture').mouseover(changetextimage(banana)); This does work: Code: var lightbulb = [1,1,1,0,1,0] var banana = [0,0,1,1,0,1] function changetextimage1(){ for(var i=0;i<5;i++){ var pixel = document.getElementById("text"+i); if (lightbulb[i]) { pixel.style.color="#000000"; } else { pixel.style.color="#FFFFFF"; } } } function changetextimage2(){ for(var i=0;i<5;i++){ var pixel = document.getElementById("text"+i); if (banana[i]) { pixel.style.color="#000000"; } else { pixel.style.color="#FFFFFF"; } } } $('#lightbulbpicture').mouseover(changetextimage1); $('#bananapicture').mouseover(changetextimage2); I have a whole bunch of these arrays (which are much longer) that I want to pass into this function so I just want to pass each as an argument rather than write each function out. I bolded the areas I'm talking about so it's easier to see. Need help please...new to JS On Form submission, I am trying to pass a variable (var radioValue, which is the RadioButton selection) as Opt Label in the _gaq.push event tracker (google analytics)as follows onclick="_gaq.push(['_trackEvent', 'Visitor', 'Submit', radioValue]);" However radioValue value is not getting passed Code snippets are attached below. Not sure whether the problem is in the JS function or whether i am calling the var incorrectly in the _gaq.push script...Thank you The radioValue is captured in the overall form validation function as below. Hari ------------------------------------------------------------- (in HTML head) /////other overall form functions var radio_choice = false; for (counter = 0; counter < document.form.RadioGroup.length; counter++) { if (document.form.RadioGroup[counter].checked == true){ radio_choice = true; radioValue=(document.form.RadioGroup[counter].value); } } if (!radio_choice) { alert("Please select again."); return (false); } /////other overall form functions ------------------------------------------------------------ RadioButton Input script (in HTML body) <input name="RadioGroup" value="abc1" type="radio" />abc1</td><td> </td></tr> <input name="RadioGroup" value="abc2" type="radio" />abc1</td><td> </td></tr> <input name="RadioGroup" value="abc3" type="radio" />abc1</td><td> </td></tr> I have added an event listener to a LI item in the DOM: liNode.addEventListener("mouseover", mouseOn, true); The mouseOn function: function mouseOn(e) { // Test for IE or Firefox var e = (!e)?window.event:e; var yPos; if (e.pageY) { yPos = e.pageY; } else { yPos = e.clientY; } } I would like to pass in another parameter to the mouseOn function in addition to the event that is passed in automatically. Is there a way to do this? I was working on a tutorial for some ajax uploading stuff and I ran across a new function syntax I don't recognize. I am not a Javascript pro, but I am not a newbie either. here is the code I am working on: Code: function handleFileSelect(e){ var files = e.target.files; var output = []; for(var i=0,f;f=files[i];i++){ if(f.type.match('image.*')){ var reader = new FileReader(); reader.onload = (function(theFile){ return function(e){ var span = document.createElement('span'); span.innerHTML = ['<img class="thumb" src="',e.target.result,'" title="',theFile.nbame,'" />'].join(''); document.getElementById('list').insertBefore(span,null); }; })(f); reader.readAsDataURL(f); } } document.getElementById('list').innerHTML = '<ul>'+output.join('')+'</ul>'; } document.getElementById('files').addEventListener('change',handleFileSelect,false); To be a little more clear, the code in question is that is the very middle. The syntax I don't understand is: Code: class.event = (function(arguments){ //stuff you put in a function... })(more Arguments?); I tried to customize a simple one to learn for myself and I wrote this: Code: var a = 'A'; var b = 'B'; test = (function(t){ alert(t); alert(b); })(b); test(a); The browser would alert 'B' and that's it. The console would tell me that 'test is not a function.' OK, so I am confused. The topmost code works. What I am wondering is what the syntax is called for creating a function (or event listener?) that way, and how it works. Although if I new what it was called I could just google how it works. Code: <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script> function getQuerystringNameValue(subid) { var winURL = window.location.href; var queryStringArray = winURL.split("?"); var queryStringParamArray = queryStringArray[1].split("&"); var nameValue = null; for ( var i=0; i<queryStringParamArray.length; i++ ) { queryStringNameValueArray = queryStringParamArray[i].split("="); if ( subid == queryStringNameValueArray[0] ) { nameValue = queryStringNameValueArray[1]; } } return nameValue; } </script> <script> function getQuerystringNameValue(uid) { var winURL = window.location.href; var queryStringArray = winURL.split("?"); var queryStringParamArray = queryStringArray[1].split("&"); var nameValue = null; for ( var i=0; i<queryStringParamArray.length; i++ ) { queryStringNameValueArray = queryStringParamArray[i].split("="); if ( uid == queryStringNameValueArray[0] ) { nameValue = queryStringNameValueArray[1]; } } return nameValue; } </head> And trying to pass into this link but its not working. Code: <map name="Map"> <area id="link-connector" shape="rect" coords="33,466,349,530" href="http://www.linkconnector.com/ta.php?lc=125601055059003882&atid=" + getQuerystringNameValue("uid") + "&ptid=" + getQuerystringNameValue("subid") + "&lcpt=0&lcpf=3"> </map> <body> Reply With Quote 01-13-2015, 07:21 PM #2 rnd me View Profile View Forum Posts Visit Homepage Senior Coder Join Date Jun 2007 Location Urbana Posts 4,497 Thanks 11 Thanked 603 Times in 583 Posts you can't use script in the middle of an attrib like that, you need to hard-code that url in whole, or build the string in JS and apply it all at once. Hi, I am facing a problem in passing replace() function as an argument in user defined java function, can any one help me how to resolve it? intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '\' to '\\' I am posting my javascript function he <a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\\/g,"\\\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a> function OpenDocPreview(url, docname) { alert('message from search base : ' + url + ' ' + docname); } thank you, Thank you in advance if someone can help. I have been banging my head against the wall for hours now. Here is the code: Code: for (var i = 0; i < BS_crm['activityTypes'].length; i++) { var clickFunc = function(){ activityList.showForm( -1, {blockType:[""+BS_crm['activityTypes'][i]['id'], "0"]} ); }; var type = { value: BS_crm['activityTypes'][i]['id'], label: "Add New "+BS_crm['activityTypes'][i]['label'], css: BS_crm['activityTypes'][i]['css']+"_16", onClick: clickFunc }; previewLinks.items.push( type ); } Now, basically what I am doing here is running through one array to create an array of objects, that will be used to create links that will use whatever onClick function I pass it. The problem is that on the second line I need the BS_crm['activityTypes'][i]['id'] to be a value, not a reference. If that line was simply changed to: Code: var clickFunc = function(){ activityList.showForm( -1, {blockType:["3", "0"]} ); }; then everything would work as I need. How can I make this happen? I would really appreciate any help. Thank you again in advance. Hi, Any one help me In one variable i have some data ex: var data = document.getElementById("imageId").value; I want to pass this data to another function inside another function ex: var button1 = '<img src="images/Remove-button.gif" width="70" height="15" onclick="removeVerifyImageRow(this),saveLibData('+data+')"/>'; while running the application i am getting an error incase if the data is string ex:if data is 'image1' i am getting an error, but with number there is no problem ex: if data is '1122'. this is very urgent to solve this problem plz any one help me I'm writing an XML generating app here, and i have come across an interesting problem. When i click on any part of the body of the document, the function addRow() is being triggered. This is odd, because the only event handler that should ever fire this is a Button that much be clicked, and it is also triggered once when the document is Loaded. The biggest question is, ...why when i click anywhere on the document, is this even being triggered. here's my code (sorry it's a bit long..but copy and paste and you should be able to replicate what i'm getting) Some notes: 1. removing the script tabber.js does not change this error. It still happens 2. removing the onLoad= in the body, and manually adding in the first table cell, and row of the table seems to fix this, however, i need to eventually load a list of table cells from a CSV file. So that workaround won't be sufficient Code: <html> <title>Site Management</title> <script type="text/javascript" src="tabber.js"></script> <link rel="stylesheet" href="example.css" TYPE="text/css" MEDIA="screen"> <script type="text/javascript"> //document.write('<style type="text/css">.tabber{display:none;}<\/style>'); </script> <script type="text/javascript"> var HumidorInnerHTML = [8]; var IntroInnerHTML = [6]; var ImageInnerHTML = [6]; var OthersInnerHTML = [8]; var WatchInnerHTML = [10]; // Intro InnerHTML IntroInnerHTML[0] = "<img src='NoImage.gif' style='height:100px; width:100px;'>"; IntroInnerHTML[1] = "<input type='textbox' id='Intro_Caption" + IntroIndex + "'>"; IntroInnerHTML[2] = "<input type='textbox' value='85' id='Intro_Height" + IntroIndex +"'>"; IntroInnerHTML[3] = "<input type='textbox' value='56' id='Intro_Width" + IntroIndex + "'>"; IntroInnerHTML[4] = "<img src='delete.png' onClick=DeleteRow('" + IntroIndex + "','Intro_Table');>"; IntroInnerHTML[5] = "<img src='add.png' onClick=AddRow('" + IntroIndex + "','Intro_Table');>"; var MyTable; var IntroIndex = 0; var ImageIndex = 0; var WatchIndex = 0; var HumidorIndex = 0; var OthersIndex = 0; function AddRow(index, DIV) { MyTable = document.getElementById(DIV); var newCell; var newRow = MyTable.insertRow(index); for (var i = 0; i < IntroInnerHTML.length; i++) { newCell = newRow.insertCell(i); newCell.innerHTML = IntroInnerHTML[i]; } IntroIndex++; } function Init() { AddRow(1, "Intro_Table"); } function DeleteRow(index, DIV) { MyTable = document.getElementById(DIV); MyTable.deleteRow(index); } function WriteXML() { // Write All XML Files // Display Tab Variables var Display_Small_Image = document.getElementById("Display_Small_Src").value; var Display_Large_Image =document.getElementById("Display_Large_Src").value; var Display_Caption =document.getElementById("Display_Caption").value; var Display_Height = document.getElementById("Display_Width").value; var Display_Width = document.getElementById("Display_Height").value; //var XMLheader = "<?xml version="1.0" encoding="utf-8" standalone="yes"?><images><pic><image>"; var XMLdata = XMLdata + Display_Small_Image + "</image>" + "<caption><![CDATA[" + Display_Caption + "<width>" + Display_Width + "</width>" + "<height>" + Display_Height + "</height>" + "<detailimage>" + Display_Large_Image; var XMLfooter = "</detailimage></pic></images>"; // Write the XML File to the Disk } </script> </head> <body onClick="Init();"> <div class="tabber"> <div class="tabbertab"> <h2>Display</h2> <p> <div> <center><b><font size="5px">Display Options</font></b></center> <br> <table> <tr> <td> <table> <tr> <td>Small Image</td><td><input type="file" id="Display_Small_Src" onChange="SmallImageChanged('Display_Small_Src', 'Display_Image_Small');"></td> </tr> <tr> <td>Full Size Image</td><td><input type="file" id="Display_Large_Src" onChange="SmallImageChanged('Display_Large_Src', 'Display_Image_Large');"></td> </tr> <tr> <td>Caption</td><td><input type="textbox" id="Display_Caption"></td> </tr> <tr> <td>Width</td><td><input type="textbox" id="Display_Width"></td> </tr> <tr> <td>Height</td><td><input type="textbox" id="Display_Height"></td> </tr> </table> </td> <td> <table> <tr> <td> <img src="NoImage.gif" style="height:150px; width: 150px; border: 1px solid red;" id="Display_Image_Small"></td><td> <img src="NoImage.gif" style="height:150px; width: 150px; border: 1px solid red;" id="Display_Image_Large"></td> </tr> </table> </td> </tr> </table> </div> </p> </div> <div class="tabbertab"> <h2>Humidor</h2> <p> <div> <center><b><font size="5px">Humidor Options</font></b></center> <br> <table border="1" id="Humidor_Table"> <tr> <td>Image</td> <td>Caption</td> <td>Height</td> <td>Width </td> <td>Picture 1</td><td>Picture 2</td><td>Remove</td> <td>Add</td> </tr> </table> </div> </p> </div> <div class="tabbertab"> <h2>Image</h2> <p> <div> <center><b><font size="5px">Image Options</font></b></center> <br> <table border="1" id="Image_Table"> <tr> <td>Image</td> <td>Caption</td> <td>Height</td> <td>Width </td> <td>Remove</td> <td>Add</td> </tr> </table> </div> </p> </div> <div class="tabbertab"> <h2>Intro</h2> <p> <div> <center><b><font size="5px">Intro Options</font></b></center> <br> <table border="1" id="Intro_Table"> <tr> <td>Image</td> <td>Caption</td> <td>Height</td> <td>Width </td> <td>Remove</td> <td>Add</td> </tr> </table> </div> </p> </div> <div class="tabbertab"> <h2>Others</h2> <p> <center><b><font size="5px">Others Options</font></b></center> <br> <div> <table border="1" id="Others_Table"> </tr> <td>Image</td> <td>Caption</td> <td>Height</td><td>Width</td><td>Image 1<td>Image 2</td><td>Remove</td><td>Add</td> </tr> </table> </div> </p> </div> <div class="tabbertab"> <h2>Watch</h2> <p> <center><b><font size="5px">Watch Options</font></b></center> <br> <div> <table border="1" id="Watch_Table"> <tr> <td>Preview Image</td> <td>Caption</td> <td>Height</td> <td>Width </td> <td>Image1</td> <td>Image2</td> <td>Image3</td> <td>Image4</td> <td>Remove</td> <td>Add</td> </tr> </table> </div> </p> </div> </div> <br> <center> <input type="button" value="Save" onClick="WriteXML();"> </center> </body> </html> The following coding works in Konqueror 3.5.10 on Ubuntu 8.04.3 LTS but not on Firefox 3.0.10 Linux/3.5.7 XP, Opera 10.10 Linux or IE8 XP. I can't see why but it may be to do with the recursion (showtable calls onclick calls addit which calls showtable ...). Somehow it is not seeing the addit routine the second time round. It is meant just to add a line. Eventually it needs to be a complex table but this is for illustration. There are other ways to solve this but this would be the simplest - if it worked! What happens is that one line is added OK but then it chokes. This is what makes me think it is the recursion but I can't see otherwise how to make it write the updated text. I realise I should have a document.close() in it as well and I have tried adding <![CDATA[ ... ]]> as well. Other than in Konqueror, it gives an error message saying object not found (in IE8) or more explicitly: Code: function onclick(event){ addit(4); } with 'addit is not defined' in Firebug. In Konqueror it works sweetly. Code: <!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' xml:lang='en' lang='en'> <head> <script language='Javascript' type='text/javascript'> if(typeof(sections) == 'undefined'){ var sections=['Text 0','Text 1','Text 2']; } function addit(ilocal){ sections.splice(sections.length,0,'Text '+ilocal); showtable(); } function showtable(){ var i,j,ip1; for(i=0;i<sections.length;i++){ ip1=i+1; document.write('Section ',i,': ',sections[i],'<br>'); } document.write("<input type='button' value='Add' onClick='addit(",ip1,")' /><br>"); for(j=0;j<sections.length;j++){document.write(sections[j]," ");} } </script> </head><body> <script language='Javascript' type='text/javascript'> showtable(); </script> </body> </html> Clues would be very much appreciated - my baldness coefficient is increasing daily! Hello im trying to make a drop down for my store, so that onchange the price of the option is displayed and my paypal buttons variables are changed. I cant get the "total" function to call when the selection of the drop down is changed. please help iv'e been looking around for a week and still havent fixed it. My event handler sets on load <body onload="x.onchange=function(){total();}"> heres my script Code: <script type="text-JavaScript"> "use strict"; /*document.getelementbyid("ddm").onchange = total;*/ var price; var title; var x = document.getelementbyid("ddm"); var size_prices= new Array(); size_prices["cards"]=18; size_prices["5x7sm"]=20; size_prices["5x7dm"]=25; size_prices["8x10sm"]=30; size_prices["8x10dm"]=35; size_prices["16x20sm"]=45; size_prices["16x20dm"]=50; function total() { y = size_prices[x.value]; document.getelementbyid("total").innerhtml = "$" + y + ".00"; title = "image title" + (x.value); document.getelementbyid("title").setAttribute("value", title); document.getelementbyid("price").setAttribute("value", y); } function verify() { } </script> here is the code for the select and the paypal button Code: <form action=""> <select name="sizes" id="ddm"> <option value="_">Please chose a size</option> <option value="cards">cards</option> <option value="5x7sm">5x7 single mat</option> <option value="5x7dm">5x7 double mat</option> </select> </form> Code: <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="verify()"> <input type="hidden" name="business" value="kin@kinskards.tcom" /> <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="add" value="1" /> <input type="hidden" id="title" name="item_name" value="Candle" /> <input type="hidden" id="price" name="amount" value="3.95" /> <input type="hidden" name="currency_code" value="USD" /> <input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" alt="paypal" /> <img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" /> </form> How do I pass an id to a function?? Or is this even possible. Code: <html> <head> <title> JavaScript array passing example </title> <script type="text/javascript"> function init(){ display(addText1); display(addText2); display(addText3); display(addText4); } function display(var myText){ var newText = '<h2>' + "Will this change anything..." + '</h2>'; document.getElementById('myText').innerHTML = newText; } </script> </head> <body onload="init()"> <div id="addText1"></div> <div id="addText2"></div> <div id="addText3"></div> <div id="addText4"></div> </body> </html> Hi, I want to pass a javascript function's return value, to an anchor tag's href parameter i.e. <a href> Suppose I have a function called getTrackingCode( ) that contains a value "testSite" Code: <script language = "JavaScript"> function getTrackingCode( ) { return "testSite"; } </script> Now I want to pass this function's value to anchor's href, I have attempted these: Code: 1. <a href="http://www.helloworld.com/?id=" + getTrackingCode( )> 2. <a href="javascript: document.location= 'http://www.helloworld.com/?id=' + getTrackingCode( );"> So that the resulting URL becomes http://www.helloworld.com/?id=testSite But none of the procedures work. Please help me do it. NOTE: Please note that I can't use the function with document.write to write the whole tag because that would be very hard to manage as I will have to use it in case of text links, image links, hotspots etc. and for each I would have to write a separate function. Furthermore, I don't want the Status bar of the browsers to show something like javascript:location.href (); etc. I want the actual href link to be seen in the Status bar, as if no javascript manupulation is done. In a nutshell, the code should be reusable for the href paramater in anchor tag's href of any element, be it a text link, image link, script link, hotspot or link area and doesn't show javascript function calling in the Status bar of the browser. I've heard that I can do such a thing using ElementbyID etc. but have no idea. Please help me with this, Thanks much! I have a function which is currently called twice on the same page. Part of the function is to apply an onkeyup event to a created element. The problem is that when the function is called twice the first created element calls the onkeyup function of the second element! table_JD.length-1 = 0 for first element table_JD.length-1 = 1 for second element updateSearch_TC_JD(1) is somehow called from first element! Code: newSearchBox.onkeyup = function() {updateSearch_TC_JD(table_JD.length-1)} Thanks for any help you can provide! I would like to pass an array to a function but how does the program know which array I would like to choose from?? Lets say I have 3 arrays and I would like to pass array C, to my function. I checked the web but they only show if you have ONLY 1 array but NOT for multiple arrays. How would I even go about doing this?? Code: var arrA=new Array("fox.com","nbc.com","abc.com", "google.com"); var arrB=new Array("car","bike","boat", "plane"); var arrC=new Array("1","2","3", "4", "5", "6", "7", "8", "9"); function display(myArray){ myArray[1] = "changed"; } display(myArray); document.writeln(myArray[1]); thanks Hi, I am having trouble passing the correct id to change the innerHTML. I have a jsp that display people and their address information. There could be several people in the list, so it is in a loop. That part all works good. There is a drop down list with countries in them. Based on the country they select, I want to change some of the text. Here is what I have: Code: <tr> <td class="datashaded" valign="top"><font size="2"><b>Country:</b></font></td> <td class="datashaded" valign="top"> <select tabindex="<%=countryTab%>" name="<%=country%>" size=1" onChange="changeText(this.form.<%=country%>, this.form.<%=addressLabel%>, this.form.<%=zipLabel%>);"> <% for (int i =0; i < countryList.size(); i++ ) { String countryOption = (String)countryList.get(i); String countryVal = bene.getAddress().getCountry(); String selected = ""; if ( countryOption.equalsIgnoreCase( countryVal ) ) selected = "selected"; %> <option value="<%=countryOption %>" <%=selected%> ><%=countryOption%></option> <% } %> </select> </td> </tr> <tr> <td class="datashaded"><div id="addr1"><font size=2><b id="<%=addressLabel%>">Address:</b></font></div></td> <td class="datashaded"> <input size=20 maxlength="50" tabindex="<%=add1Tab%>" name="<%=address1%>" value="<%=address1Value%>" </td> </tr> Everytime through the loop, addressLabel has an index added to it so it is unique - so I can refer to each person separately. Here is the js function: Code: function changeText(sel, txtField1, txtField2) { var selectedValue = sel[sel.selectedIndex].value; if ( selectedValue == "<%=IParticipantConstants.BENEFICIARY_COUNTRY %>") { document.getElementById(txtField1).innerHTML = 'Address:'; document.getElementById(txtField2).innerHTML = 'Zip:'; } else { document.getElementById(txtField1).innerHTML = 'Street or P.O. Box'; document.getElementById((txtField2).innerHTML = 'Postal Code:'; } } When I hardcoded the id= value, not matter which group I changed the country on, only the first one was changing, so I knew I needed unique ids for each group. There is more to the table, but this is the good part. When the onChange fires now, Nothing at all happens. Can anyone see the problem?? Thanks for looking! Hello I am trying to call a javascript autocomplete function but I want to use a variable instead of an input field ID So this is my fuction: Code: $(function() { $("#tags").autocomplete({ source: "search.php?field=field1" }); }); <p><b>Field:</b><input type="text" input id = "tags" name="field1" size="60" ><br> Basically I want to use the same function for numerous input fields, so how can I pass a var instead of the input id ? Any help would be appreciated Hi, I was wondering if i can pass my php variables through javascript function. Actually i have a simple table of pictures, when clicked in the picture a new popup page comes up, it working fine uptill this stage but now i want to pass a value through it, for instance if user clicks on picture1 then my popup url should be "item_large.php?id=pic1 My Javascript junction for the popup window: Code: function popup() { window.open("item_large.php","Register","menubar=no,width=500,height=400,toolbar=no"); } My Html code where i have my pictures: Code: <td height="19" align="center" valign="top" onmouseover="this.bgColor='#CC3300' ; this.style.cursor='pointer'" onmouseout="this.bgColor='#FFFFFF'" <A HREF="javascript:popup()">Picture01</A> </td> Thanks |