Jump to content

Macchiato

Members
  • Content Count

    38
  • Joined

  • Last visited

Everything posted by Macchiato

  1. Yes, it is necessary to allow wrong guesses. Thank you for your version John
  2. Your answer is quiete thorough, thanks Hadien
  3. I'd like to achieve the following with javascript:When you type any of the following words into the inputbox and click the submit button you'll be redirected to the corresponding page:tree => tree.phpchocolate => chocolate.phpbird => bird.phpcandle => candle.phpapple => apple.phpHowever if you type a different word than the above, you'll get a warning message. <div id="main"> <form action=""> <ul> <li><input class="inputbox" type="text" name="TypeWord" value="" placeholder="Type a word here"/></li> <li><input class="but
  4. Instead of using the "disabled" property, I want to use an other method to make Select unclickable. The problem with the "disabled" property is that the form field result will not be send to the server. I found a solution to this problem, by turning "disabled" off when you click the submit button: <script type="text/javascript">function observeFlavor(flavor, requires) { document.getElementById(flavor).onchange = function(){ if(document.getElementById(flavor).options[1].selected == true) { document.getElementById(requires).options[1].selected = true; document.getElementById(requires).
  5. With some help I managed to get the following script: <script type="text/javascript">function observeFlavor(flavor, requires) { document.getElementById(flavor).onchange = function(){ if(document.getElementById(flavor).options[1].selected == true) { document.getElementById(requires).options[1].selected = true } }} observeFlavor("chocolate","icecreamcone");observeFlavor("vanilla","icecreamcone");</script> However, the above script doesn't disable the field. Maybe instead of disabling the field you make it unclickable when vanilla or chocolate, or both are selected. But whe
  6. The following script seems to work, but has two problems: - It uses jQuery- It ignores note 2. $( "select" ).change(function() { if ( $( "#vanilla" ).val() == "yes" || $( "#chocolate" ).val() == "yes" ) $( "#icecreamcone" ).val( "yes" ); else $( "#icecreamcone" ).val( "addicecreamcone" );});
  7. For example, if you select the option with id="chocolate-yes" or id="vanilla-yes", the the option with id="icecreamcone-yes" will also be selected.As you can see on the image below, when you select the option with id="chocolate-yes", <select id="icecreamcone"> will be disabled. When both id="chocolate-yes" and id="vanilla-yes" are not selected the the option with id="icecreamcone-no" will not be disabled. To put it in simpler words: you always need to have an ice cream cone if you want to add vanilla or chocolate ice cream, with the exception of sprinkles Anyone know of a Javascript tha
  8. Woah! Take it easy man... eat a pie I always try before I post. Already found a solution: <script type="text/javascript"> var els = ["first_field", "fourth_field", "sixth_field"] for (var i = 0; i < els.length; i++) document.getElementById(els[i]).disabled = true; </script>
  9. I'd like to disable certain input boxes, but without changing the HTML code manually. For example:I'd like to disable the input boxes with the following id's:id="first_field"id="fourth_field"id="sixth_field" <div> <form action=""> <fieldset> <input type="text" id="first_field"/> <input type="text" id="second_field"/> <input type="text" id="third_field"/> <input type="text" id="fourth_field"/> <input type="text" id="fifth_field"/> <input type="text" id="sixth_field"/> </fieldset> </form> </div> Anyone kno
  10. Works like a charm, thanks Justsomeguy!
  11. In this example you cannot change the properties of the input element with type="text". I've changed the html code to make the intention more clear: <div> <form action=""> <fieldset> <input type="text" name="boat" id="boat" disabled="disabled" value="n/a"> <input type="text" name="car" id="car" disabled="disabled" value="2"> <input type="text" name="dog" id="dog" disabled="disabled" value=""> </fieldset> </form></div> <div> <div id="button_boat"><input type="button" value="Boat"/></div> <div id="button_c
  12. The script must be run when the page is loaded. The content of the fields cannot be changed, so instead use this html: <!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>Hide Button When Input Value Is Empty</title></head><body> <div> <form action=""> <fieldset> <input type="text" disabled="disabled" id="first_field" value="1"/> <in
  13. I'd like to hide the corresponding button when an input value is empty or has a value="n/a". In the following example, the input box "first_field" is corresponding with the button "first_button", and the input box "second_field" with the button "second_button", and so on... In this case the second and fifth button will be hidden: <!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>Hi
  14. Thanks ShadowMage! Just a wee bit
  15. Thanks for your reply thescientist. I used getTextAndPutInElement(id), but that messes up my page. getTextAndPutInElement("text")however seems to work. getTextAndPutInElement("text") did the trick! I had to play a bit where to put it, but I found the right spot now. Thanks a million
  16. 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
  17. You're right, it works! I had no idea it was compatible with your code, thanks dsonesuk Updated code here
  18. I replaced: totalEl.innerHTML = "$"+totalVal; with: totalEl.innerHTML = "$"+totalVal.toFixed(2); To get $1999.00 instead of $1999 I was wondering, what do you have to change to the code to get a comma (,) in the amount, so you get $1,999.00 instead of $1999.00 See an example of the code here
  19. Thank you for notifying me, I hadn't even noticed that yet Updated the code here
  20. That did the trick! Thank you so much dsonesuk! P.S. I've updated the example, you can find it here
  21. I got the following code: function addCommasandsign(nStr) {nStr += '';x = nStr.split('.');x1 = x[0];x2 = x.length > 1 ? '.' + x[1] : '';var rgx = /(\d+)(\d{3})/;while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2');}return '$' + x1 + x2; }//get htmlvar firstval=document.getElementById('firstAmount').innerHTML;var secval=document.getElementById('secondAmount').innerHTML;//replace $ and , by nothingfirstval=firstval.replace('$','');firstval=firstval.replace(',','');secval=firstval.replace('$','');secval=firstval.replace(',','');//add valuesvar total=firstval + secval;//put
  22. 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
  23. Works like a charm, many thanks!
  24. You mean like this? ... Total: <p id="total">$0.00</p> <script type="text/javascript">function getAmountAndPutElsewhere(id) { var checkForThisID = document.getElementById(id); var getAmountSelects = checkForThisID.getElementsByTagName("select"), L = getAmountSelects.length, i; for (i = 0; i < L; i++) { getAmountSelects[i].onchange = calcTotal; } function calcTotal() { var totalEl = document.getElementById("total").innerHTML = value; totalVal = 0,
  25. What needs to be changed to the code if I want to send the total amount to a P element instead of the value of the inputbox? Total: <p id="total">$0.00</p> instead of:Total: <input id="total" type="text" disabled="disabled" value="$0.00" />
×
×
  • Create New...