JavaScript - Simple Html Inline (in The Line) Insertion Of A Js Var
There are some VERY similar questions and answers, but I have been unable to get them to work for me.
The simple situation is calculate days since a date with JS, and output it as part of a text line: create variable xxx with subtraction, or datediff() <body> <p>XYZ has been in effect for (xxx) days.</p> </body> Nothing more, & thanks. Reply With Quote 01-17-2015, 03:40 PM #2 sunfighter View Profile View Forum Posts Senior Coder Join Date Jan 2011 Location Missouri Posts 4,830 Thanks 25 Thanked 672 Times in 671 Posts When I have a question about javascript I go to w3schools JavaScript Tutorial or MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript. FYI datediff() is not an official JS function. What I normally do is get the date as a UTC number (millsecs after an old date) do the math and then convert back. Code: <!DOCTYPE html> <html lang="en"> <meta charset="utf-8" /> <head> <title></title> </head> <body> <div id="her" style="clear:both;"></div> <script type="text/javascript"> var d1 = new Date("january 01, 2015"); var d2 = new Date(); var work = d2.getTime() - d1.getTime(); var xxx = Math.round(work/86400000); document.getElementById("her").innerHTML = 'XYZ has been in effect for '+xxx+' days.'; </script> </body> </html> The number 86400000 comes from 1000*60*60*24 to convert millisecs to days Similar TutorialsHello, everyone... I have this problem that is really bugging me. I am trying to implement this script found in Javascriptkit: http://www.javascriptkit.com/script/...ltooltip.shtml It has a very unique feature of grabbing arbitrary HTML tags and attaching tooltips to them. Priceless to my site. But the problem is, the script only works with jQuery up to 1.2.6... after that version, it stops working entirely. Quite an issue, as you can imagine. It also has some issues with browsers other than Firefox that I hope updating the code might fix. I don't have any lead on this... could anybody look into the code and tell me what's wrong? Thank you, Hi, I have what is probably a stupid issue. I have a select box that is being filled by an an ajax request to a SQL DB and returns the results in a select box. That part works fine. The second part of the request is that i also want my inline html to change results if i change my selection. that part is not working. I tried to put my onchange event into the option in php, but that doesn't return anything either. $display_string .= "<option onchange=\"getSoftwareUpdate();\"> $row[Software] </option>"; clear as mud? Any help would be much appreciated! //this section gets the results from the php script and returns back the values in the db. <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function getSoftwareFunction() { var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Please contact Trinity Help Desk at ext. 88817"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var SoftwareName = document.getElementById('results').value; var ManufacturerName = document.getElementById('results').value; var VersionName = document.getElementById('results').value; var InstallLocationName = document.getElementById('results').value; var queryString = "?Software=" + SoftwareName + "&Manufacturer=" + ManufacturerName + "&Version=" + VersionName; + "&InstallLocation=" + InstallLocationName ajaxRequest.open("POST", "getSoftwareName.php" + queryString, true); ajaxRequest.send(null); } </script> //this next part i want to return the results based on an onchange event in the select option <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function getSoftwareUpdate() { var ajaxRequest1; // added try{ // Opera 8.0+, Firefox, Safari ajaxRequest1 = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest1 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Please contact Trinity Help Desk at ext. 88817"); return false; } } } //added // Create a function that will receive data sent from the server ajaxRequest1.onreadystatechange = function(){ if(ajaxRequest1.readyState == 4){ var ajaxDisplay1 = document.getElementById('ajaxDiv1'); ajaxDisplay1.innerHTML = ajaxRequest1.responseText; } } //end add var Software = document.getElementById('results').value; var SoftwareName = document.getElementById('results').value; ajaxRequest1.open("POST", "getSoftwareName1.php" + SoftwareName, true); ajaxRequest1.send(null); } </script> <html> <div id='ajaxDiv1'></div> <div id='ajaxDiv'> <select id='results' onchange="getSoftwareUpdate();" name="Software"> </select> </div> </html> </td> can some please tell me what this line does... Code: <div onClick="getElementById('tInfo').onclick();"> I am trying to create a WYSIWYG editor for my site, but seeing as how every browser gives different results when using the execcommand method, I am trying to do my own insertions instead. What I would like to do is create an iframe with designMode On to enable editing of the frame, but when someone does a command to bold text, I want to make a method which enters <b>Some Highlighted Text</b> into the frame where the user highlighted so it would appear bold and the source would have the <b> tags. My issue is I have been unsuccessful in learning how to take the selected text within an iframe and surround it with tags. I was able to accomplish this in Internet Explorer using this code: Code: //iFrame is the object handling the frame var text = iframe.document.selection.createRange().text; var obj = iframe.document.selection.createRange(); obj.text = '<i>' + text + '</i>'; Except the resulting text would actually have the <i> tags appear, and the source would be: Code: <i>Some Text</i> Pretty retarded if you ask me since in no way did I want it to convert the tags into entities. Anyway, if anyone could please direct me to a method in which I can successfully take selected text within the iframe and surround it with HTML tags in such a way that the formatting will actually show, I would be very grateful ^_^. Hey all, i could really use some help in making life easier if any one can help. Im gonna try my best and explain what i want but please excuse my lack of knowledge! What i want to achieve is to use one page as a template that can take information from the url and use it to produce the result i want for example if the template page is template.html ad it looked something like this: Code: <title> + title + </title> </head> <body> <a href="http://www.mywebsite.com/ + folder + / + page +">Click Here</a> </body> </html> The link to the page could look something like this: template.html?folder=football&page=united.html&title=United Scores this would result in the template page rendering as: Code: <title>United Scores</title> </head> <body> <a href="http://www.mywebsite.com/football/united.html">Click Here</a> </body> </html> If anyone can tell me how i can achieve this i would be extremely grateful. Thanks I am allowing my customers to use a rich text editor (wysiwyg) on a jsp page to create snippets of HTML code that can be used to describe their items. When they want to add an image, table or custom tag (something we wrote), they are presented with a properties box created using javascript on the same page just below the editor. Upon clicking 'Insert' button on the properties box, I use javascript to create an HTML string with the tag information and insert the string into the edited page where the cursor was. The problem is that I can't seem to find a reliable way to know where the cursor was. More information: I am a C programmer who morphed to a Java programmer who knows some javascript. The JSP page looks like this: -------------------------------------------------------------------- Some text and text fields for some basic information -------------------------------------------------------------------- The javascript wysiwyg editor -------------------------------------------------------------------- The properties box (changes depending on the type of item being inserted) -------------------------------------------------------------------- Submit button, etc. for the page (so the information can be persisted) I have tried: 1. Seven days of searching the web for helpful hints. 2. Using a popup window to get the properties (doesn't work because in IE7, closing the popup also kills the session... I need to use some of the beans on the main window on the popup.) 3. Processing onMouseDown and onKeyDown events storing the element information in a global variable so I could use it later to know the point of insertion. (Has not been reliable and the arrow keys present real problems with where the cursor ends up as that is different from where it was pressed.) I am frustrated because I don't seem to be gaining on the problem. I suspect it is because I have missed something very simple. Does anyone have any ideas? Thanks in advance. Carl OMYG this error has kicked me dead: An error occurred in script '/var/www/html/admin/tabs.php' on line 54: Use of undefined constant title - assumed 'title' function tab( $title ) { global $tabs; $text=""; if ( count( $tabs ) > 0 ) endtab(); $tabs []= array( title => title, text => '' ); } Code: <?php $tabs = array(); function tabs_header() { ?> <style type="text/css"> .tab { border-bottom: 1px solid black; text-align: center; font-family: arial, verdana; } .tab-active { border-left: 1px solid black; border-top: 1px solid black; border-right: 1px solid black; text-align: center; font-family: arial, verdana; font-weight: bold; } .tab-content { padding: 5px; border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; } </style> <?php } function tabs_start() { ob_start(); } function endtab() { global $tabs; $text = ob_get_clean(); $tabs[ count( $tabs ) - 1 ][ 'text' ] = $text; ob_start(); } function tab( $title ) { global $tabs; if ( count( $tabs ) > 0 ) endtab(); $tabs []= array( title => $title, text => "" ); } function tabs_end( ) { global $tabs; endtab( ); ob_end_clean( ); $index = 0; if ( $_GET['tabindex'] ) $index = $_GET['tabindex']; ?> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <?php $baseuri = $_SERVER['REQUEST_URI']; $baseuri = preg_replace( "/\?.*$/", "", $baseuri ); $curindex = 0; foreach( $tabs as $tab ) { $class = "tab"; if ( $index == $curindex ) $class ="tab-active"; ?> <td class="<?php echo($class); ?>"> <a href="<?php echo( $baseuri."?tabindex=".$curindex ); ?>"> <?php echo( $tab['title'] ); ?> </a> </td> <?php $curindex += 1; } ?> </tr> <tr><td class="tab-content" colspan="<?php echo( count( $tabs ) + 1 ); ?>"> <?php echo( $tabs[$index ]['text'] ); ?> </td></tr> </table> <?php } ?> I've been given the challenge of creating a simple simulation in Javascript and html. Here are the criteria: - A bunny occupies a meadow that is 30 units wide and 30 units long. - The bunny has a limited amount of energy. 1000 units to start. - The bunny can only move one spatial unit per unit time. Each movement may be in any direction. - Each time the bunny moves, it spends 1 unit of energy. - The meadow is bathed by sunlight, and the soil is fertile and rich. Plants grow in the meadow. These plants can be eaten by the bunny. Each plant boosts the energy of the bunny by ten units. When the plant is eaten by the bunny, it should no longer be present in the meadow. - Plants grow at random in the meadow. - Plants boost the bunny's energy by 10 units - No two plants may occupy the same space in the meadow. So far, I have the bunny moving properly and its energy adjusting properly, but I can's seem to figure out how to visually add plants to the meadow. My current code is below: HTML: Code: <div id="energyFeedback" style="width:300px; height:10px; border:1px solid #666;"> <div id="energyFeedbackBar" style="width:100%; background-color:#999; height:100%;"></div></div> <div id="gameContainer" style="position:absolute; top:30px;"> <div id="meadow" style="width:300px; height:300px; background-color:#957E52; position:absolute; left:0px; top:0px;"> <div id="bunny" style="position:absolute; height:10px; width:10px; background-color:#FCC;"></div> </div> </div> JS: Code: //The bunny will start in the center of the meadow... therefore 15units in x & 15units in y directions var bunny = {name: "Bunny", x: 15, y: 15, energy: 1000}; //as plants are created, they will get pushed into this array: var allPlants = []; //Graphic stuff // Create a reference to the HTML element on screen so that you can move it around bunny.graphic = document.getElementById('bunny'); energyFeedbackBar.graphic = document.getElementById('energyFeedbackBar'); //growthFactor will determine how likely a plant is to grow. Modify this value to answer the question above. var growthFactor = 0.5; //make a list of directions of travel for our Bunny var directions = [ n = {x: 0, y: -1, name: "North"}, e = {x: 1, y: 0, name: "East"}, s = {x: 0, y: 1, name: "South"}, w = {x: -1, y: 0, name: "West"},]; //setInterval will make the program run every 100ms (in this case) var int = setInterval(Simulation,100); //intervalCount will keep track of our units of time expended var intervalCount = 0; //clear the interval (once the angriest bunny has been determined) function stopInt() { clearInterval(int); }; //this function gives a random element from an array (directions in our case) function randomElement(_array) { if (_array.length == 0) throw new Error("The array is empty."); return _array[Math.floor(Math.random() * _array.length)]; }; //the moveBunny function will take the bunny and and move it in a random direction function moveBunny() { // if the bunny is still alive... if (bunny.energy > 0) { //choose a random direction by running our "directions" array through our randomElement function. var directionOfMovement = randomElement(directions); //the bunny's position is changed by adding a random value to his x and y coordinates var newPosX = bunny.x + directionOfMovement.x; var newPosY = bunny.y + directionOfMovement.y; //we must constrain the bunny's movement to within the 30 by 30 meadow if (newPosX < 0 || newPosX > 30) { //basically, if the bunny lands beyond 30px or before 0px in the x or y directions, // their value gets reset to the min or max distances. if (newPosX > 30) { bunny.x = 30; } else { bunny.x = 0; } } //If they fall within the meadow, the bunny's x and y value are now updated to the new value. else { bunny.x = newPosX; } if (newPosY < 0 || newPosY > 30) { if (newPosY > 30) { bunny.y = 30; } else { bunny.y = 0; } } else { bunny.y = newPosY; } } else{ stopInt(); }; //move bunny graphically on the browser. bunny.graphic.style.left = (bunny.x * 10) + 'px'; bunny.graphic.style.top = (bunny.y * 10) + 'px'; console.log(bunny.name + " moved to x: " + bunny.x + ", y: " + bunny.y + ", " + directionOfMovement.name); //bunny's health is reduced by 1 unit per movement. bunny.energy -= 1; //represent this graphically in the browser by adjusting the width of the energyFeedbackBar to represent the bunny's current energy level. energyFeedbackBar.graphic.style.width = (bunny.energy/10)*3; console.log(bunny.name + " has " + bunny.energy + " units of energy left."); }; function createPlant() { //*********************************Here is where the problem begins...*********************************** //the plant needs to appear on the screen as a small green square (approx 5 by 5px) within the 30 by 30px meadow. //Every plant created must be pushed onto the array 'allPlants' so that it can be compared to the position of the bunny. //I thought that maybe divs could be dynamically generated but I'm not sure if this is the most effective way, or if I'm even doing this properly. I tried this below: /*var plant = document.createElement("div"); plant.id = "plant" + intervalCount; plant.style.x = Math.floor(Math.random()*30) + "px"; plant.style.y = Math.floor(Math.random()*30) + "px"; plant.style.width = 5 + "px"; plant.style.height = 5 + "px"; plant.style.background = "#090"; document.documentElement.appendChild(plant); console.log("plant created at x: " + plant.x +" and y: " + plant.y);*/ }; //Simulation will determine whether a plant grows, //...moves the bunny //... and compares the position of the bunny to the position of all the plants. function Simulation(){ //To keep track of time, add to the intervalCount intervalCount++; //state time in the console console.log("Time: " + intervalCount +" units"); //grow a plant randomly (dependant on the growth factor) if (Math.random() < growthFactor) { createPlant(); } //move the bunny moveBunny(); // Compare bunny's position to the plants' positions, if there are plants. if (allPlants.length >= 1) { for (var j = 0; j < allPlants.length; j++) { // compare x and y co-ordinates if (bunny.x == allPlants[j].x && bunny.y == allPlants[j].y) { console.log("The bunny ate a plant!"); //increase bunny's energy bunny.energy = bunny.energy + 10; // *********Here the plant must also be removed from allPlants and removed visually from the meadow*********** }; }; }; }; Any help with this generation of plants would be appreciated! Hi everyone, I am new to javascript, i have not read any books, but i am trying to figure out the language on the go. I am stuck with a simple program that i am trying to create for a class project. Any suggestions or help would much appreciated. My code is very simple in which i would like to convert a number value into different format of temperature. My code is listed below, it is not working in the browser. Help me fix it. ********************************************************* <!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 content="text/html" http-equiv="Content-Type" /> <title>E6B temp conversion</title> <script type="text/javascript"> function ConvertTempToC(TempConversionC) { var temperature = TempConversionC.F.value; if (temperature.length > 0) { TempConversionC.TempC.value = Math.round(5/9 * (temperature - 32)); document.write(TempConversionC.TempC.value); } } </script> </head> <body> <b>Fahrenheit to Celsius</b> <br/> <input size="6" name="F"/> <br/> <input onclick="ConvertTempToC(this.form)" value="Calculate Celsius" type="button" name="Submit11"/> <br/> <input readonly="readonly" size="6" name="TempC"/> </body> </html> I'm trying to convert A world Population Counter from Flash into HTML/Javascript. But I'm having difficulties and It would be great if someone can help me out. The sample show a analog clock, But the html version I want should use just a digital clock, it's simpler I think http://www.webstylelabs.com/worldclock2.swf http://www.webstylelabs.com/actionscript.txt Here is my code, http://www.webstylelabs.com/clock.html So just plain input digital counter is ok I appreciate any help I am very new to javascript and really can't figure out what I am doing wrong. I am trying to make a 1 page store that allows you to type in an item and select the color and size you want for that item. If you don't fill in a field, an alert message should tell you that. If all the fields are filled in, a "thank you for purchasing ____________" message should appear in a text area at the bottom of the page. This is my current code: Code: <html> <head> <script> function processform() { if ( document.form1.item1.value == "") { alert("No Item Chosen") } else { chosen = "" len = document.form1.c1.length for (i = 0; i <len; i++) { if (document.form1.c1[i].checked) { chosen = document.form1.c1[i].value } } if (chosen == "") { alert("No Color Chosen") } } else { itemname = document.form1.item1.value; itemcolor = document.form1.c1.value; itemsize = document.form1.size.value; document.form1.txtarea1.value = "Thank you for purchasing a " + itemsize + " " + itemcolor + " " + itemname; } } </script> </head> <body> <h1>Store</h1> <br/><br/> <form name="form1"> <h4>What item would you like to buy?</h4> <input type="text" name="item1" value="" /><br /> <br/><br/> <h4>Color</h4> <input type="radio" name="c1" value="blue" /> Blue<br /> <input type="radio" name="c1" value="red" /> Red<br /> <input type="radio" name="c1" value="green" /> Green<br /> <input type="radio" name="c1" value="yellow" /> Yellow<br /> <br/><br/> <h4>Size</h4> <select name="size"> <option value="small">Small</option> <option value="medium">Medium</option> <option value="large">Large</option> <option value="extra large">Extra Large</option> </select> <br/><br/> <button onclick="processform()">Purchase</button> <br/><br/> <textarea rows="2" cols="40" name = "txtarea1"> </textarea> </form> </body> </html> When I press the purchase button, no alert message is shown, nor does anything get displayed in the textarea. What am I doing wrong? Hello I am pretty new to AJAX & I am making a simple program to input new text refresh inside the HTML element that has the id='result'. My Problem: - The AJAX script fails when I try to change the text inside 'result' using my code, sometimes a whole new page opens with the text I wanted to put inside the result HTML element. Sometimes I just get a notification that an error occured. - I believe it is because of my function state_changed & using the parameter element_id with the function getElementById(element_id).innerHTML = ...; - It should be easy to see where my problem occurs when you look at my code Any advice on why the script fails & how to fix it would be extremely helpful. Code: var xmlHttp; function ajax_compatible() { // Post: Returns an object if browser is AJAX compatible else false. if (window.XMLHttpRequest) { // users web browser can support AJAX return ( new XMLHttpRequest() ); } else if (window.ActiveXObject) { // users web browser is IE6 and IE5 return ( new ActiveXObject("Microsoft.XMLHTTP") ); } else { alert("Unfortunately your browser does not support AJAX."); return null; } } function get_cookie(cookie_name) { if (document.cookie.length > 0) { c_start = document.cookie.indexOf(cookie_name + "="); if (c_start != -1) { c_start = c_start + cookie_name.length+1; c_end = document.cookie.indexOf(";",c_start) if (c_end == -1) { c_end = document.cookie.length; } return unescape(document.cookie.substring(c_start,c_end)) } } return "" } function add_comment() { // Post: Add user comment & rating to database and update new table row. // DO WE NEED TO SEND COOKIE ASWELL OR IS IT ALREADY DONE??? xmlHttp = ajax_compatible(); if (xmlHttp == null) { return; } var url = 'http://localhost:8000/cgi-bin/main.py'; alert("add_comment() running"); // Extract CGI variables to pass onto python script var id = document.getElementById('videoID').value; var video_id = 'videoID=' + id; var rating = 'rating=' + document.getElementsByName('rating').value; var comment = 'comment=' + document.getElementById('comment').value; var add_rating = 'addRating=' + document.getElementById('addRating').value; //var cookie = document.cookie; cgi_var = video_id + '&' + rating + '&' + comment + '&' + add_rating; // + '&' + cookie; // open python script xmlHttp.open('POST',url,true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // Error is in below line xmlHttp.onreadystatechange = state_changed(id); // if I use the following line then it works // xmlHttp.onreadystatechange = test; xmlHttp.send(cgi_var); } function state_changed(element_id) { // Post: Use one function that will be used for each page update. // This function sends the text returned by the python server script // onto the browser(HTML element with the id 'element_id') to be displayed. if (xmlHttp.readyState == 4) { document.getElementById(element_id).innerHTML = xmlHttp.responseText; } } function test() { // Post: used to test where the problem occurs // This function works if (xmlHttp.readyState == 4) { document.getElementById('result').innerHTML = xmlHttp.responseText; } } Hi, I'm working on a simple website in which I'm required to use two types of forms input on a webpage. I have decided to make a simple quiz which will be designed as follows; -------------------------------------------------------- Q1: The largest mammal on land is: (radio button choices) Q2: Please tick the two correct answers: (tick boxes, four available... only two correct) ---------------------------------------------------------- (BUTTON: Please click here for the answers) ... answers should appear once the above button is pressed... Answers: Q1: B Q2: A * C Is this possible in a simple way? Sounds quite straight-forward but I'm no expert so forgive me.. Ps: Is it possible to design a radio button which, depending on the choice, the related-text will appear underneath on the same page? So if they select 'A' then paragraph 'A' will show, if they select 'C' then paragraph 'C' will appear (with the rest hiding)... Thanks 4 your time! I have been working on the code for an alpha sort file and have become stumped. I need to incorporate both an insertion sort & selection sort method into my code before it will run. I attached the file I have been working on and it runs on Bluej with Java JDK. I would apretiate if you could take a look at it. If you would prefer not to download my file I have posted my code that I have been working on below. I am not familiar with the structure of an insertion sort or a selection sort mothod. I also am not clear on the point in which these methods would need to be placed in the file. Code: import java.io.*; import java.util.*; public class Words { ArrayList<String> words; public Words() { words = getData("wordlist.txt"); } public void displayWords() { for(int i=0; i<words.size(); i++) { System.out.println(words.get(i)); } } public ArrayList<String> getData(String filename) { ArrayList<String> list = new ArrayList<String>(); File myFile = new File(filename); if(myFile.exists() && myFile.length()>0) { try { BufferedReader in = new BufferedReader( new FileReader(myFile) ); String word = in.readLine(); while( word != null ) { list.add(word); word = in.readLine(); } } catch( Exception e ) {} } return list; } } Hi i have some inline code that i would prefer to transfer into javascript functions and place in a .js file in the head or foot of my webpage. I have tried to convert into funtions myself but could not get to work. Would appreciate any help to give me the correct working code. thanks. Here is the portion of code from inside a working form: <button id="decbtn" onclick="updbtn.style.background='url(images/wuc.gif)';qty.style.background='';decrement(this.parentNode.getElementsByTagName('input')[0]);return false;">-1</button> <input id="qtyinp" name="qty" onkeyup="updbtn.style.background='url(images/wuc.gif)';qty.style.background='url(images/packindic.png) no-repeat bottom right #ffffff';this.value=this.value.replace(/[^\d]/,'');return false;" maxlength="3" value="0" type="text"> <button id="incbtn" onclick="updbtn.style.background='url(images/wuc.gif)';qty.style.background='';increment(this.parentNode.getElementsByTagName('input')[0]);return false;">+1</button> <input name="pid" value="A0517A" type="hidden"> <button id="updbtn" type="submit" onclick="this.style.background='';qty.style.background='url(images/upd.png) no-repeat right top #ffffff';">Update</button> I have following HTML code: Quote: <br/> <div style="display:none">.....</div> <div style="display:none">.....</div> How can I modify display to block in style attribute with Javascript? i have some really annoying issues with a widget which is known inline modal you can see that widget after you click the play button in the given link below, please help me out, the issue is that use google chrome and then go to this place, the link is: http://www.bloghuts.com/2010/09/star-island.html and in this page click on play, then you yourself will see the error, please tell me what to do with this error. And another problem is that again open the above link in internet explorer and click the play button you will see a different kind of annoying problem, except these two explorers it works fine, PLEASE HELP ME I WOULD REALLY BE THANKFUL TO YOU. Hello, I'm sure someone on this site is familiar with Lightforms AJAX contact forms. I've downloaded one and am attempting to integrate with my current Contact page. Lightform comes with 3 external .js sheets one of which is formcheck.js. While Lightform has sufficiently functioning and nicely styled JS which checks for valid inputs in the text fields, I would also like to add watermark text in a few of the text fields. I pretty much had what I wanted on my own form until I tired to mix it as inline code with with Lightform Contact form. Here is the mixtu Code: <input id="name" name="name" type="text" class="validate['required','length[3,-1]','nodigit']" size="20" value="Mr., Ms., Pastor..."onBlur="if(document.getElementById('name').value=='') {document.getElementById('name').value='Mr., Ms., Pastor...'};" onfocus="document.getElementById('name').value=''"; /> Perhaps someone can tell me why my watermark effect won't happen anymore. thanks for your time. Alright, I'm using a Rooh.It WordPress plugin right now, but I don't like the way they do it, so I want to write my own code to do something similar. I want the user to be able to select the text they want to highlight, and the background color of that text changes to whatever color they have selected. How can I do this in JavaScript? Hi, The following code works: Code: <html> <head> <style type="text/css"> img { opacity:0.4; filter:alpha(opacity=40); } </style> </head> <body> <img src="http://www.w3schools.com/Css/klematis.jpg" width="150" height="113" alt="klematis" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" /> <img src="http://www.w3schools.com/Css/klematis2.jpg" width="150" height="113" alt="klematis" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" /> </body> </html> But the problem is you have to repeat the inline JavaScript for all <img> tags. I tried to put the script in the head to no avail: Code: <html> <head> <style type="text/css"> img { opacity:0.4; filter:alpha(opacity=40); } </style> <script type="text/javascript"> function getElements() { var x=document.getElementsByTagName("img"); x.style.opacity=1; x.filters.alpha.opacity=100; } </script> </head> <body> <img src="http://www.w3schools.com/Css/klematis.jpg" width="150" height="113" alt="klematis" onmouseover="getElements()" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" /> <img src="http://www.w3schools.com/Css/klematis2.jpg" width="150" height="113" alt="klematis" onmouseover="getElements()" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" /> </body> </html> Everything seems right to me, but it doesn't work. Many thanks for any help! Mike |