JavaScript - Returnvalues As Parameters For Html-tags
Similar TutorialsI 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. Hello there, I have one drop down list having some characters name. I have created this list dynamically using javascript. I have <h3> tag in html having same characters' name using that I had created drop down list. There are <blockquote> along with <h3> tag which is speech of that character. I have to generate the javascript in such a way that, if character "A" is selected and sppech belong to that character should be visible. Is any one help me? my following code able to match <h3> tags and hiding it but not working properly. Please help me out. Code: function selectedOption() { var indx = newSel.selectedIndex; var selectedText = newSel.options[indx].text; h3Tag = document.getElementsByTagName("h3"); var nestedH3; //alert(h3Tag); bQuote = document.getElementsByTagName("blockquote"); for(var i=0; i<h3Tag.length; i++) { tagName[i]=h3Tag[i].innerHTML; if(selectedText != tagName[i] && selectedText != "Show All Lines") { //alert("Char: "+tagName[i]); h3Tag[i].style.display = "none"; bQuote[i].style.display = "none"; } else if(selectedText == "Show All Lines") h3Tag[i].style.display = "block"; } } Hi, I wanna make a form that receives: textbox URL And textbox Anchor and result will be two anchors one <a href, and one phpBB Example: Url: www.pushpin.co.il Anchor: pushpin Results: <a href="http://www.pushpin.co.il">pushpin</a> [ url = http://www.pushpin.co.il/ ] pushpin[ /url ] Help? I came across some embedded JavaScript code and I noticed some weird “HTML comment-like tags” within embedded JavaScript that are getting rendered in FireFox but not IE. Specifically the closing tag "//-->" And the JavaScript code between these tags is functional (not commented out)! Code: <SCRIPT type=text/javascript> <!-- .... //--> </SCRIPT> What are these? Example usage: Code: <SCRIPT type=text/javascript> <!-- var zz, zv, d, fTSR; d = new Date(); fTSR=0; zv = d.getTime(); zz = "&zz="+zv; var gBF=false; function GoTo(u){window.top.location = u + zz;} function Go(u){window.top.location = u;} .... //--> </SCRIPT> Hi, I have a text area that I want to add simple html formatting buttons to. The user should be able to: - highlight text and click a 'bold' button - highlight text and click 'itallic' button - Add bulleted list - Link I've looked at a number of WYSIWYG javascript examples, but they seem to accept Microsoft Word formatting, which I dont want. I'm using javascript to change the color of certain words in an html document. Right now it uses <font> to make the change. I would like to use a CSS class named "alert" from an external style sheet to make the change. I've tried multiple things but no luck (className="alert", setClassName="alert" ) What is the correct way to replace the font part with a CSS class? Here is the working script: Code: <script type = "text/javascript"> window.onload = function (){ var text = document.getElementsByTagName('body')[0].innerHTML; text = text.replace(/disabled/gi, "<font color=red>Disabled</font>" ); text = text.replace(/\blocked/gi, "<font color=red>Locked</font>" ); document.getElementsByTagName('body')[0].innerHTML = text; } </script> Well after much trial and error I come asking for help. I am trying to write a greasemonkey script that scans a page for all the values between certain <td> tags. When I used firebug it shows what I am looking for as <td class="username">THEUSERNAME</td> but when I view the source it just shows up as <td>THEUSERNAME</td> I want to create an array of the 100 <td>'s on the page that pertain to usernames but none of the other <td>'s I created a test page that mimicked the code, what I thought origionally, to be so I could test my script with ease. And it worked when there was an actually <td class="username"> This is what I have so far: Code: // ==UserScript== // //Displayable Name of your script // @name EXAMPLE // // brief description // @description EXAMPLE // //URI (preferably your own site, so browser can avert naming collisions // @namespace http://something.com // // Your name, userscript userid link (optional) // @author ME // //Version Number // @version 1.0 // // Urls process this user script on // @include http://example.com // ==/UserScript== var test = document.getElementsByClassName('username'); alert(test.length); test[5].style.color="yellow"; //Just to see if it actually worked Dear All, Here I am facing one issue, that I want to removing all html tags except BOLD,ITALIC,UNDERLINE & UL,LI. Means if my data is like, <b><i> Test Data </b></i> <input type="text" name="test"> <script> function test() { ............. } </script> Then I want the following output.... <b><i> Test Data </b></i> function test() { ............. } Means I need the data with tags BOLD,ITALIC,UNDERLINE & UL,LI not any else tags..... I have tried with this strInputCode.replace(/<[^>]+>/ig,""); but its removing all html tas that i dont want How do I replace the string "rpg" only present in between <et> tags ? Code: <et>ReplaceOnlyrpg</et> After replacement it should look like this Code: <et>ReplaceOnly</et> Any advice is appreciated. Thank you 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! Hello, 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 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 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 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/ 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 [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 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! 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 |