Jump to content

Search the Community

Showing results for tags 'put'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 4 results

  1. The following code retrieves the text from the element with id="Text" and puts it in the element with id="putText": <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Get text and put in element</title></head> <body> <p id="Text">$1,200.00</p> <p id="putText"></p> <script type="text/javascript">function getTextAndPutInElement(id) { var source = document.getElementById(id); var target = document.getElementById("putText"); target.innerHTML = source.innerHTML;}getTextAndPutInElement("Text");</script> </body></html> The problem is that $1,200.00 is generated by an other script. When the page is loaded, you will have this result: <p id="Text">$1,200.00</p><p id="putText">$1,200.00</p> But in the meantime the text can change: <p id="Text">$1,500.00</p><p id="putText">$1,200.00</p> The script with function getTextAndPutInElement only runs ones when the page is loaded, so it doesn't know the text has been changed in the meantime. The content of the element with id="Text" looks something like this: <p id="Text">function otherScript(id) {...code that changes the text}</p> How can you load this script: function getTextAndPutInElement(id) { var source = document.getElementById(id); var target = document.getElementById("putText"); target.innerHTML = source.innerHTML;} everytime function otherScript is run?
  2. I´d like to get the amount between "(+$" and ")" and add it to the value of the inputbox. For example, you select the following:Solero Exotic (+$1.85)Cappuccino (+$2.49)iMac 27-inch 3.1GHz (+$1,999.00) These amounts will be subtracted from the options you've selected:1.852.491,999.00 The inputbox will display: 2003.34 But here's the tricky part, I need to do this without changing the existing attribute values or adding new attributes to the Option tag. Anyone know a javascript code that can do this? If possible, please post a sample. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Get Amount And Put Elsewhere</title></head> <body> <form action=""> <fieldset> <ul style="list-style:none;padding-left:0;"> <li>Ice Cream: <select class="optionsIceCream" name="IceCream"> <option value="IceCream01">Select Ice Cream</option> <option value="IceCream02">Solero Exotic (+$1.85)</option> <option value="IceCream03">Magnum Ecuador (+$4.85)</option> <option value="IceCream04">Cornetto Enigma (+$2.00)</option> </select> </li> <li>Coffee: <select class="optionsCoffee" name="Coffee"> <option value="Coffee01">Select Coffee</option> <option value="Coffee02">Cup of Joe (+$0.99)</option> <option value="Coffee03">Cappuccino (+$2.49)</option> <option value="Coffee04">Latte Macchiato (+$2.99)</option> </select> </li> <li>Computers: <select class="optionsComputers" name="Computers"> <option value="Computer01">Select Computer</option> <option value="Computer02">Dell Inspiron 620 (+$449.99)</option> <option value="Computer03">HP Pavilion dv7t (+$949.99)</option> <option value="Computer04">iMac 27-inch 3.1GHz (+$1,999.00)</option> </select> </li> </ul> Total: <input class="totalAmount" type="text" disabled="disabled" value="0.00" /> </fieldset> </form> </body></html>
  3. I have two amounts, each one in an element. I'd like to add them together and put them in an other element. Anyone know a Javascript that can do this? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Add amounts and put in element</title></head> <body> <p id="firstAmount">$1,133.79</p> <p id="secondAmount">$1,900.00</p> <br /> Total: <p id="totalAmount">$0.00</p> </body></html>
  4. I have a Javascript that retrieves the text from between the "p" tags and put it in the title value, like this: before:<option title="" value="Put Text">Put Text</option> after:<option title="$1,179.83" value="Put Text">Put Text</option> The only problem is, it doesn't work in ie6-8. Does anyone know how to make this code work in ie6-8? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Get text and put in attribute value</title></head> <body> <div class="Text"><p>$1,179.83</p></div> <form action=""> <fieldset> <select class="putText" name="put-Text"> <option id="" class="putTextOption" value="Put Text">Put Text</option> </select> </fieldset> </form> <script>window.onload=function() { var pTag = document.getElementsByClassName("Text")[0].getElementsByTagName("p")[0]; var amount = pTag.innerHTML; document.getElementsByClassName("putTextOption")[0].title=amount;} </script> </body></html>
×
×
  • Create New...