Jump to content

Chocolate570

Members
  • Posts

    1,550
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Chocolate570

  1. Here's a calculator I made, if you'd like to look through it. I made it a couple months ago. It was on page 14 of the javascript forum. :)

    <head><title>Calculator</title><style type="text/css"><!--form {width: 150px;border: outset 3px #000000;}input {width: 30px;background-color: #dedede;color: #000000;border: double #0000ff 3px;}input:active {background-color: #ff0000;}input.window {width: 132px;background-color: #ffffff;color: #000000;}input.sum {width: 132px;}--></style><script type="text/javascript">function foc(){zah()document.forms.myForm[0].focus()}function numberletter(){z = "0"while (z == "0"){x = document.forms.myForm[0].valuey = x.lengthif(y == 0){ return}for(i = 0;i<y;i++){ z = "0" for(j=0;j<10;j++) {  if(x.substring(i,i+1)==j)  {   z="1"  } } if(z=="0")   {  if(i==0)  {   document.forms.myForm[0].value=x.substring(1,y)  }  else  {   document.forms.myForm[0].value=x.substring(0,i)+x.substring(i+1,y)  }  i=99 }}}}function operator(operator){document.forms.myForm[17].value=operatordocument.forms.myForm[18].value=document.forms.myForm[0].valuedocument.forms.myForm[0].value=""}function alrt(){alert("BKAH")}function calculate(first,second,operator){if (first.length==0){alert("Please enter 2 numbers and an operator before calculating.");zah()return}if (second.length==0){alert("Please enter 2 numbers and an operator before calculating.");return}if (operator.length==0){alert("Please enter 2 numbers and an operator before calculating.");return}if (operator=='+'){var y=eval(first)+eval(second)document.forms.myForm[0].value=y}if (operator=='-'){var y=eval(first)-eval(second)document.forms.myForm[0].value=y}if (operator=='*'){var y=eval(first)*eval(second)document.forms.myForm[0].value=y}if (operator=='/'){var y=eval(first)/eval(second)document.forms.myForm[0].value=y}}function clrlast(){var v = document.forms.myForm[0].valuevar l = v.lengthif(l > 0){var b = v.substring(0,l-1)document.forms.myForm[0].value=b}}function zah(){document.forms.myForm[0].value=""document.forms.myForm[18].value=""document.forms.myForm[17].value=""}function called(num) //start function that recieves button clicks{var blah=document.forms.myForm[0].valuelength = blah.length //put the length of the text box into "length"if(!(num=='0' && length==0)) //checking if the first digit in the box is not 0{x=document.forms.myForm[0].valuey=x+numdocument.forms.myForm[0].value=y}num="" //undefine variableslength="" //""document.forms.myForm[21].value=blah}</script></head><body onload="foc()"><fieldset><form name="myForm"><center><table><tr><td colspan="4"><input class="window" type="text" dir="rtl" value="1" onchange="numberletter()"></td></tr><tr><td><input type="button" value="7" onclick="called('7')"></td><td><input type="button" value="8" onclick="called('8')"></td><td><input type="button" value="9" onclick="called('9')"></td><td><input type="button" value="+" onclick="operator('+')"></td></tr><tr><td><input type="button" value="4" onclick="called('4')"></td><td><input type="button" value="5" onclick="called('5')"></td><td><input type="button" value="6" onclick="called('6')"></td><td><input type="button" value="-" onclick="operator('-')"></td></tr><tr><td><input type="button" value="1" onclick="called('1')"></td><td><input type="button" value="2" onclick="called('2')"></td><td><input type="button" value="3" onclick="called('3')"></td><td><input type="button" value="*" onclick="operator('*')"></td></tr><tr><td><input type="button" value="0" onclick="called('0')"></td><td><input type="button" value="C" onclick="clrlast()"></td><td><input type="button" value="CA" onclick="zah()"></td><td><input type="button" value="/" onclick="operator('/')"></td></tr><tr><td colspan="2"><input type="hidden" value=""></td><td colspan="2"><input type="hidden" value=""></td></tr><tr><td colspan="4"><input class="sum" type="button" value="              =              "  onclick="calculate(document.forms.myForm[18].value,document.forms.myForm[0].value,document.forms.myForm[17].value)"></td></tr></table></center></form></fieldset></body>

  2. You can do that with cookies. If you'd really like, I can make it so that when it's got a background, it sets a cookie with it's value to the background. The next time it opens the page, it checks if the bg image it's supposed to put is not in the cookie, meaning it's different from last time. Do you want that?And my god, my php worked. I can't believe it. This really is amazing to me :)

  3. Ok. Got it. :)Rename your page to pagename.php, first of all.Next, put this in the head section, AFTER the CSS.

    <?php$randthing = rand(1,max number here);#Where it says max..., put the last number that can be included. 1,20 means #a number between 1 and 20, AND including 1 and 20. switch($randthing){  case "1":  $finstyle="url of first image";  break;  case "2":  $finstyle="url of second image";  break;  case "3":  $finstyle="url of third image";  break;  #Ok, you get the idea. Continue with that format until done.  default:  exit("OMG IT DOESN'T WORK LOLOLOLOL");  #K, put the message that displays if it doesn't work there.   break;}$omgfirst='<style type="text/css">body{background-image:url(';$omglast=');}</style>';echo $omgfirst.$finstyle.$omglast;?>
    K, you know how bad I am at php. So try that out. :)
  4. One sec, i'll put a script together.

    <script type="text/javascript">x=new Array();x[0]="image one"x[1]="image two"//keep going, you get the idea.random = Math.floor(Math.random()*x.length);startTep='<style type="text/css">body {background:url('+x[random]+');}</style>'document.write(startTep);</script>

    Does that work?

  5. Pollux is correct. PHP does not know what type of element it is retrieving info from. But this is how to do it. Beware---the user has to click a submit button for it to work.

    <form method="POST" action="the current php page you're on"><input blahblahblah name="daaaa"><input blahblahblah name="LOLOLOL"><input type="submit" value="OMG"></form><?php$da = $_POST['daaaa'];$lol = $_POST['LOLOLOL'];echo $da.$lol;?>

  6. :) When you put the script in a seperate window, it works perfectly. And as a coincidence, a friend of mine just designed a blog system. It's very simple to set up. I could ask him to give the code to you?
  7. One of the longest running tv series' in the world. It's like star wars---except it's set in the future, and they're on this ship, and they fly around, saving people. Klingon is a type of race in that series. They speak..klingon. :)

  8. He's right, read the tutorials, but your example is wrong, real.This is the code:

    <script type="text/javascript">var url="put the url of the website you wanna go to"var yesorno=confirm("Wanna go to another site??")if(yesorno==true){window.location=url}</script>

  9. First michael, add this to the tag that, when mouseovered, should bring up the pop up:

    onmouseover="popUp()"

    Then, put this in your head section:

    <script type="text/javascript">function popUp(){window.open("somepage.html", "windowname", "width=300, height=150");}</script>

    And remember to edit the window.open() function. Hope that helps!Choco

  10. I think for a project like this, we'd need 10 people. Also, I think that we shouldn't do every language available, just major ones--javascript, CSS, ASP, SQL, HTML, PHP, and that sort of thing. Otherwise, doing the... 40+ language tutorials available on W3S would take FOREVER. :)

×
×
  • Create New...