Jump to content

unistake

Members
  • Posts

    445
  • Joined

  • Last visited

Everything posted by unistake

  1. thanks for your help, works well! Can you explain this code though * ((op=='add')?1:-1); Is there any way i could use if functions rather than the above, as I understand them a lot more *edit = spelling der!
  2. Hi all, I am having trouble with a very basic calculator Ive been trying to get working. Basically there are 2 text boxes and 2 radio buttons. each of which either add or subtract the 2 numbers entered in the text fields. I am hoping someone could correct the script or atleast show me where I have gone wrong Thanks <script> function calculator() { var type = document.getElementById('radio'); if(type.value == "add") { total = document.calcform.box1.value + document.calcform.box2.value; result.InnerHTML = total; } else(type.value == "subtract") { total = document.calcform.box1.value - document.calcform.box2.value; result.InnerHTML = total; } } </script> <form name="calcform"> <label> <input name="box1" type="text" id="num" value="4"> </label> <label> <input name="box2" type="text" id="num" value="5"> </label> <label> <input type="radio" name="radio" id="radio" value="add" onClick="return calculator();"> add </label> <label> <input type="radio" name="radio" id="radio" value="subtract" onClick="return calculator();"> subtract </label> <div id="result">output is here</div> </form>
  3. never mind guys i give up! there will be another way of what im trying to do Cheers
  4. the script as above works for the 'sr' and 'snr'. As i believe it, "text" is for the div id for where the result is shown. What would you recommend it to be instead of what is posted above?
  5. thanks for the help div. I have done all the changes, and there seems to be the same problem as before. It changes the 'sr' and 'snr' values but not the 'qualifier'. The variables are all being sent through - thats the only part im 100% sure on! That part of the script now looks like: function calc(v){ if(v== "qualifier") qualifier(); else if (v== "sr") sr(); else if(v== "snr") snr(); } function qualifier (){ var stake = freebet.value; var bodds = backodds.value; var lodds = layodds.value; total = (stake + bodds + lodds); text.innerHTML = 'this is the total value ' + total }
  6. nice to have a bit on banter! OK, I have changed all the names and ids to the same value 'typeofbet' but I still dont know where I have gone wrong! my whole page is here in shell form! Please fill in the blanks. I have been working on this for over a week! <head> <script> function calc(){ // if radio button value is 'qualifier' // if(value == "qualifier"){ qualifier(); } // if radio button value is 'sr' // else{ if(value == "sr"){ sr(); } // if radio button value is 'snr' // else{ if(value == "snr"){ snr(); } } } } function qualifier (){ var stake = freebet.value; var bodds = backodds.value; var lodds = layodds.value; result = ((stake * bodds) / lodds); text.innerHTML = 'the result is ' + (result) } function sr(){ text.innerHTML = 'this is the sr!' } function snr(){ text.innerHTML = 'this is the snr!' } </script> </head> <body> <form name="calcform" id="calcform"> <input name='freebet' type='text' value='25'/><br> <input name='bodds' type='text' value='3.2'/><br> <input name='lodds' type='text' value='3.3'/><br> <input type='radio' name='typeofbet' id='typeofbet' value='qualifier' onclick='return calc();'><br> <input type='radio' name='typeofbet' id='typeofbet' value='sr' onclick='return calc();'><br> <input type='radio' name='typeofbet' id='typeofbet' value='snr' onclick='return calc();'><br> <span id='text'>results displayed here</span> </form> </body> Thank you so much
  7. ah! missed the link - thanks
  8. MrAdam, thanks for the reply. where would i put that, whilst creating a table in mysql? Could you give me an example? thanks
  9. Hi all, In my mysql database I have a small note about a product e.g. "this retails at £29.99". The problem is that when I come to echo this $note in php it does not display the £ character but a black diamond shape with a question mark in it! The mysql field is a VARCHAR length 100. How can this be changed so it displays the £ sign? Thanks
  10. i cant seem to get that loop to work, any more ideas on simpler scripts?!
  11. actually scrap that last post. Is there another way to achieve the same result as I have made above? Basically the user inputs numbers in a form, clicks one of three radio buttons, and depending on the radio button option calculates a couple of formulas and displays it on the same page without a re-load. Thanks for the help
  12. Hi Haku, thanks for that reply. Would you mind explaining it further? I am not so sure what you mean - I am new to JS.. go easy on me! Thanks
  13. Hi all, I am trying to search for a tutorial/script for this sort of Javascript application seen here http://www.dibusoft.com/ - where the text changes when the user scrolls through the different picture frame images. Thanks
  14. thanks for the reply. so is there an alternative to 'getElementsByName()' and also can I change the doctype to something other than what it is at the moment?
  15. I have a webpage with javascript and a html form in it, as seen in the code below, which works fine without using <!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"> on the top of the webpage. I was hoping someone could point me in the right direction why my javascript would not work with this standard piece of code. Thanks. The full page code that I am talking about is: <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function calc(){ text = document.getElementById("text"); selection = document.getElementsByName("typeofbet"); for(i=0; i<selection.length; i++){ if(selection[i].checked == true){ var selected = selection[i].value; } } if(selected == "qualifier"){ qualifier(); }else{ if(selected == "freesr"){ sr(); }else{ if(selected == "freesnr"){ snr(); } } } } function qualifier (){ bcommission = 0; lcommission = 5; var stake = freebet.value; var bodds = backodds.value; var lodds = layodds.value; backreturn = bodds * stake-(bcommission*((bodds-1)*stake)/100)-0; laystake = backreturn / (lodds-lcommission/100); liability = laystake * (lodds-1)+0.01; layprofit = laystake * (100-lcommission)/100; profitloss = (stake - layprofit); text.innerHTML = 'In bookmaker, stake the team with £' + CurrencyFormatted(stake) + ' on odds of ' + CurrencyFormatted(bodds) + '<p> In Betfair, LAY the team with £' + CurrencyFormatted(laystake) + ' on odds of ' + CurrencyFormatted(lodds) + '<p> You will make a small loss of £' + CurrencyFormatted(profitloss) + ' to get the free bet amount of £' + CurrencyFormatted(stake) } function sr(){ text.innerHTML = 'this is the sr!' } function snr(){ text.innerHTML = 'this is the snr!' } function CurrencyFormatted(amount) { var i = parseFloat(amount); if(isNaN(i)) { i = 0.00; } var minus = ''; if(i < 0) { minus = '-'; } i = Math.abs(i); i = parseInt((i + .005) * 100); i = i / 100; s = new String(i); if(s.indexOf('.') < 0) { s += '.00'; } if(s.indexOf('.') == (s.length - 2)) { s += '0'; } s = minus + s; return s; } </script> </head> <body> <form name="calcform"> <table width="379" border="0" cellspacing="4" cellpadding="0"> <tr> <td colspan="2"><img src="images/2.png" alt="" width="125" height="30"></td> <td width="204"> </td> </tr> <tr> <td width="33"> </td> <td width="142"><span class="style28">free bet £</span></td> <td><span class="style2"> <input name="freebet" type="text" id="freebet" style=" border: 1px solid #EFEFEF; background-color:#FFF; height:25px;" size="15" /> </span></td> </tr> <tr> <td> </td> <td><span class="style2">back odds</span></td> <td><input name="backodds" type="text" id="backodds" style=" border: 1px solid #EFEFEF; background-color:#D2E1E9; height:25px;" size="15" /></td> </tr> <tr> <td> </td> <td><span class="style5 style20">lay odds</span></td> <td><input name="layodds" type="text" id="layodds" style="border: 1px solid #EFEFEF; background-color:#EACBDB; height:25px" size="15" /></td> </tr> <tr> <td> </td> <td><span class="style6 style1">Type of Bet</span></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><span class="style6 style1"> <input type="radio" name="typeofbet" value="qualifier" onClick="return calc();"> qualifier <input type="radio" name="typeofbet" value="freesr" onClick="return calc();"> stake-returned <input type="radio" name="typeofbet" value="freesnr" onClick="return calc();"> stake-not-returned</span></td> </tr> <tr> <td colspan="2"><img src="images/3.png" width="110" height="30" /></td> <td><span class="style1"></span></td> </tr> <tr> <td> </td> <td colspan="2"><p> <span class="style1" id="text">this is text</span> </p></td> </tr> </table> </form> </body> </html>
  16. ok cheers, do you have an answer to my other post ive just put on ? cheers
  17. i put it on the wrong thread, so i re-posted and it was moved! wont happen again
  18. Hi again! I also have a problem with 'echoing' variables within a text string. I am trying to get the output here to say: 'this is the qualifier! £25' <html> <body> <script type="text/javascript"> function calc() { var fb = freebet; text.innerHTML = 'this is the qualifier! £' + fb; } </script> <form name='calcform'> <input name="freebet" type="text" id="freebet" value="25"> <input type="submit" name="button" id="button" onClick="return calc();"> <span id="text"></span> </form> </body> </html> any ideas? thanks
  19. Thanks for the reply, can you tell me how to stop it going to the head of the page?
  20. Hi all, got a simple problem for you I am trying to create an outcome by clicking on radio buttons, I cant seem to get the 'document.write' to work and display the text at the bottom of the radio buttons, with those radio buttons still showing. The code I have is: <html> <head> <script type="text/javascript"> function calc (){ selection = document.getElementsByName("typeofbet"); for(i=0; i<selection.length; i++){ if(selection[i].checked == true){ var selected = selection[i].value; } } if(selected == "qualifier"){ qualifier(); }else{ if(selected == "freesr"){ sr(); }else{ if(selected == "freesnr"){ snr(); } } } } function qualifier (){ document.write('this is the qualifier!'); } function sr(){ document.write('this is the sr!'); } function snr(){ document.write('this is the snr!'); } </script> </head> <body> <form name="calcform"> <p> <input type="radio" name="typeofbet" value="qualifier" onClick="return calc();"> qual <input type="radio" name="typeofbet" value="freesr" onClick="return calc();"> sn <input type="radio" name="typeofbet" value="freesnr" onClick="return calc();"> snr </p> </form> </body> </html> Thanks for the heads up
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.