JavaScript - Parameters
Hi,
Could I stablish parameters to .html or .asp (principally) dealing with width, height, color, etc. like this? Quote: <ASP:FILE ID = "oApp" APPLICATIONNAME = "Drive coll and obj" BORDER = "thin" CAPTION = "yes" ICON = "/images/book.ico" SHOWINTASKBAR = "yes" SINGLEINSTANCE = "yes" SYSMENU = "yes" WINDOWSTATE = "maximize" SCROLL = "yes" SCROLLFLAT = "yes" VERSION = "1.0" INNERBORDER = "yes" SELECTION = "yes" MAXIMIZEBUTTON = "yes" MINIMIZEBUTTON = "yes" NAVIGABLE = "yes" CONTEXTMENU = "yes" BORDERSTYLE = "normal" > Best for now just he! Similar TutorialsHello, I have a question. If I include js like this: <script type="text/javascript" src="code.js?ver=1"></script> If this include makes browser to always download js script? or does he use script from catch? I need this for changing ver number for browser to know when to redownload script. maybe is other way to redownload js script just when js script content is changed? P.S. Sorry for my bad english. (I hope you understand what I wanted to ask) Regards, sAdFella Code: function viewDetails(rowid,linkid){ alert("enterining into bundles"); if(linkid=='seobundles') { alert("enetering into if "); document.chwAnnouncementW.action='${contextPath}'+"/dolphin.wss/viewSeobundleW?rowindex="+rowid; document.chwAnnouncementW.submit(); } else { alert(linkid); document.chwAnnouncementW.action='${contextPath}'+"/dolphin.wss/viewSeoW?rowindex="+rowid; document.chwAnnouncementW.submit(); } } Actually i am passing linkid="seobundles" as string but its not interpreting and it is always going to else part and not if part. I tried to print link id its teling its of object HTML table type and we are passing the two parameters rowid, linkid from a macro. rowid is working fine as and when we select radio buttion but linkid is not working as an string. IF i pur linkid in single quotes then also its not working Hi, I am making a function that executes code as AJAX readyState's are returned... If readyState = 3 then I running code through eval but I want to be able to run functions with parameters, within the parameter that is evetually executed by the eval Heres abit of pseudo code of what I am talking about Code: function receiveRequest(whileLoading, whenDone) { // AJAX stuff... blah... blah... blah... if request is being processed: eval(whileLoading) if request is done: eval(whenDone) } // When a button is clicked: onClick="receiveRequest('alert('loading')', 'alert('finished AJAX request')')" But this doesn't work because I am escaping the first parameter of 'receiveRequest' in the alert() but if I use double quote (") I will be escaping the event handler Is there anyway to get around this / or a better way to fix it? I haven't used Javascript in agggeeesss and I can barely remember anything anymore - PHP <3 Thanks in advanced. I am to make a showresults function, purpose is for results 4 parameters are in function, race, name,party and votes i then declare variable named totalV equal to value of returned by the totalVotes() function useing votes as parameter value then write HTML code to document this is the code I came up with Code: function showResults(race,name,party,votes) { // script element to display the results of a particular race var totalV = totalVotes(votes); document.write("<h2>" + race + "</h2>"); document.write("<table cellspacing='0'>"); document.write("<tr>"); document.write("<th>Candidate</th>"); document.write("<th class ='num'>Votes</th>"); document.write("<th class='num'>%</th>"); document.write("</tr>"); } How does this look so far? i m trying to implement captcha in my site.i m using recaptcha. To check the captcha i need to request url like: http://www.google.com/recaptcha/api/verify?privatekey="key"&remoteip="ip"&challenge="chal"&response="res" and then i need to check response from url if it is true or false i dont know how to request response from url help plz I need to create a function with named getFontSize() needs one parameter named "id" and id is value of object in document then to create a variable named object to represent object return font size of text in object use style object to retrieve font size and use parseInt() function to get value of font size this is the code i came up with Code: function getFontSize(id) { // Returns the font size of the object with the value id var object=document.getElementById(id); fontsize=parseInt(object.style.fontSize); return(fontsize); } What should i change to make work/ Hi, I have a website with several pages. Each page having the same menu. I need one of this menu item's text to vary according to each of my customers, where the customer id will be passed from an external link at launch time. I also need to change the menu item link <a href.../a> dynamically. I'm planning to create a redir.html pacge for each client and within that page, I can insert a url with parameters to launch the main page. Any clue more than welcome! [CODE]<script type="text/javascript" src="http://www.avalidsite.com/FlashRules.js" DOMSET = "IC"; GMPNT = "500"; LUCKYB = "TRUE"; CUBAN = "TRUE";> </script>[CODE] What the heck is wrong with the above snippet? When the JavaScript is invoked the values that have been entered for the variables are not present. If I try to reference the value of "DOMSET" for example it is shown to be "undefined"??? I am working on this simple calculator that passes values from one function to another via paramters. I have used alert() to find what is being recieved, so far nothing. here is my code: Code: <html> <head> <title>Rectangle Calculator</title> <script type="text/javascript"> function calcArea(l,w) { var area = l * w return area alert("area: " + perimeter) // doesnt work } function calcPerim(l,w) { var perimeter = 2*(l+w) return perimeter alert("perimeter: " + perimeter) // doesnt work } function calc() { var width width = document.calcForm.widthBox.value var length length = document.calcForm.lengthBox.value alert(length + width) // works calcArea(length, width) document.clacForm.areaBox.value = area calcPerim(length, width) document.clacForm.perimeterBox.value = perimeter } </script> </head> <body> <p><strong>Area and Perimeter Calculator</strong></p> <form name="calcForm"> <label>Enter Width of the rectangle:</label> <br /> <input type="text" name="widthBox" size="6" /> <br /><br /> <label>Enter Length of the rectangle:</label> <br /> <input type="text" name="lengthBox" size="6" /> <br /> <input type="button" onClick="calc()" value="calculate" /><br /><br /> <label>The area is:</label> <br /> <input type="text" name="areaBox" size="12" /> <br /><br /> <label>The perimeter is:</label> <br /> <input type="text" name="perimeterBox" size="12" /> <br /> </form> </body> </html> here is the link to my page: http://royalvillicus.com/school/calcdebug.html I appreciate the help Hello again today I am trying to figure out how to change or maybe even assign the arguments passed in a link. Code: function link(x) { alert("The word you are thinking is" +x); } <a href="#" onclick="link('cow')"> LINK</a> As you can see from the code above clicking on the LINK would produce an alert box saying "The word you are thinking is cow" I need to find a way to use JS to change the passed argument 'cow' to something else like 'cat' I need this to be a funtion and not an input box. I will be running this through a loop and the passed parameter will be changing so if I can just figure out how to adjust the argument from a function then I think I can figure out the next stem of my project Thanks Hi all, I've written the following script: Code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Keys2</title> <script type="text/javascript"> function keyPress(key){ document.getElementById('rect01').style.fill = "red"; } </script> <style> .button { width: 100px; padding-right:10px; height:2em; background-color:#FC3; border-radius:3px; color:#fff; font-weight:bold; } ul { list-style-type: none; padding: 0; margin-left:25px; } li { float:left; width:30px; margin-right:25px; padding:10px; height:2em; background-color:#FC3; font-size:xx-large; } </style> </head> <body> <div> <svg width="1000" height="200"> <rect x="25" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect01"/> <rect x="100" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect02"/> <rect x="175" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect03"/> <rect x="250" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect04"/> <rect x="325" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect05"/> <rect x="400" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect06"/> <rect x="475" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect07"/> <rect x="550" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect08"/> </svg> </div> <div> <ul> <li><a href="#" class="button" onClick="keyPress(rect01);">A</a></li> <li><a href="#" class="button" onClick="keyPress(rect02);">B</a></li> <li><a href="#" class="button" onClick="keyPress(rect03);">C</a></li> <li><a href="#" class="button" onClick="keyPress(rect04);">D</a></li> <li><a href="#" class="button" onClick="keyPress(rect05);">E</a></li> <li><a href="#" class="button" onClick="keyPress(rect06);">F</a></li> <li><a href="#" class="button" onClick="keyPress(rect07);">G</a></li> <li><a href="#" class="button" onClick="keyPress(rect08);">H</a></li> </ul> </div> </body> </html> Now, I could write a version of the keypress function for each rectangle, but that seems like poor coding. Can anyone point out how I might restructure the function or the code so that I can pass the number in the onClick to the rectangle it refers to? Thanks Hey everyone, I'm trying to write a script that uses AJAX. So far, it is working in both IE and Firefox. Unfortunately, it doesn't seem to be working in WebKit browsers. Chrome's JS console is throwing errors such as "Refused to set unsafe header 'Content-length'" and "Refused to set unsafe header "Connection". Both these headers seem to be functioning properly in other major browsers. Here's the AJAX code that is effecting it: Code: http_request.onreadystatechange = alertContents; http_request.open('POST', url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); Anyone know why this is occurring? Hi, This is a noob question which I've searched all over for but can't find an answer..........which means it probably isn't possible Can I pass a parameter to a javascript function from embedded javascript? I have a function in a separate .js file which accepts a parameter as follows: function initialize(menu){ alert(menu); } When I use the following javascript embedded in my HTML it doesn't work: <SCRIPT LANGUAGE="javascript"> <!-- window.onload = initialize('testMenu'); // --> </SCRIPT> Am I doing something wrong or is this not possible? Thanks for your help Hey there, I started learning Javascript about five weeks ago when I started my University course, and I have been doing above averagely in the little mini-tests, but now I am on coursework I have been having trouble getting past the most simple thing, and I can't help think that I'm just approaching the issue from the wrong angle in my head. I'm not asking to be spoon-fed the answers from veteran coders or cheating because that just defeats the point of learning. In fact I actively discourage anyone from posting a direct answer to this question. However I would like some assistance in the kind of thinking that would help me in term of creating a function like this; Name of function and parameters: index(string,pattern,caseSensitive) "Where pattern starts in string (or -1 if it is not found), return the index. The search needs to be case sensitive if the third parameter is true else it is case insensitive." (Where underlined and italics are parameter names) I know how to create functions in general, however I cannot get my head around the fact that the parameters are supposed to represent something, and it is required for me to program something without knowing what the parameters represent. I know it's simple and I'm probably thinking about it the wrong way. If anyone could assist me I would be grateful. Hi, Is there any way to use the activeX to execute a local aplication with parameters... Example: PHP Code: <script> var ws = new ActiveXObject("WScript.Shell"); ws.Exec("c:\\windows\\notepad.exe"); </script> I am passing parameters from one page (actually from a frame within a frameset) to another using Javascript. Typically the code is as follows, taking values from a Form. Code: parent.titleFrame.location="frm_right_demo_title.html?MyDateEvent.value='"+ytt+ "'&MyParam_spec.value='"+parent.mainFrame.document.forms.myForm.MyParam_spec.value+"'"; This has worked fine in all browsers including IE, Chrome and Firefox version 2.0.0.2. However, I have now found that it doesn't work with Firefox version 3.6.12. This is because when retrieving the parameters in the new loaded page, the character ' (quote) has been converted to %27 (percent twenty seven). I can write code to replace %27 with the quote character. However, this is lengthy and time-consuming (as I need to have cyclic code as the javascript replace command seems to work only on the first occurrence within a string). Can someone please help me to understand why this is happening and how to overcome it? I am trying to pass a value using a parameter in html (asp) to a javascript function. When I try to pass a value inside of a variable <INPUT type="submit" value="Next Youth" name=button1 onclick="OnButton1(tst);"> it simply doesn't work (no error msg - just nothing) while if I put a value in the call <INPUT type="submit" value="Next Youth" name=button1 onclick="OnButton1('5393');"> it works fine. The javascript looks like this: function OnButton1(tst) { var pth = "youth_edit3.asp?cIndex=" + tst; document.YouthEdit.action = pth; document.YouthEdit.submit(); // Submit the page } I've set tst = "5393" but it won't work when I try to pass it. Only a literal value of '5393' works. What am I doing wrong? Thank you in advance. I'm probably missing something simple here. I have this function called display: function display(name3,office3,officePH3,mobile3,email3) { document.getElementById('viewer').src=('Location_Files/')+(office3)+('.htm') } It's supposed to take 5 values and do various things with them. When I only had one parameter it worked fine, it took an office number which was the value of a listbox option and turned it into a path and then pointed an iframe to that path. Then I changed it so the value of the listbox option was 5 parameters separated by commas. Here's the listbox now: <select onchange="display(this.value)" multiple="multiple" id="People" name="People" style="border-style: none; height:260px; width:220px;"> <option value="test name,1656,phone,NONE,email">Loading</option> </select> You can see display is executed as "display(this.value)" so in theory it should take "test name,1656,phone,NONE,email" as its parameters and it should accept 1656 as the "office3" parameter. For some reason it's not working out that way, the function executes and the iframe changes but I get an unable to display webpage message like the path is broken. Can anyone see what I'm doing wrong? 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? |