Jump to content

hacknsack

Members
  • Posts

    183
  • Joined

  • Last visited

Posts posted by hacknsack

  1. You're Welcome.I think you are out of wishes in this thread... :) (I'm kidding of course)Well drive this around the block:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head>  <title>Banner Colorizer</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  <style type="text/css">.noShow{ display: none;  width: 350px;  padding: 5px; }.yesShow{ display: block;  width: 350px;  color: #CA02B6;   cursor: pointer;  padding: 5px; }  </style><script type="text/javascript">var bgArray = ['#FDC1F7','#FDB0F5','#FD9FF3','#FD8EF2','#FD79F0','#FD55EC','#FD2FE9','#EA02D2','#FD2FE9','#FD55EC','#FD79F0','#FD8EF2','#FD9FF3','#FDB0F5','#FDC1F7','#FFFFFF'];var fgArray = ['#EA02D2','#FD2FE9','#FD55EC','#FD79F0','#FD8EF2','#FD9FF3','#FDB0F5','#FDC1F7','#FDB0F5','#FD9FF3','#FD8EF2','#FD79F0','#FD55EC','#FD2FE9','#EA02D2','#CA02B6'];var fadeArray = ['#FD55EC','#FD79F0','#FD8EF2','#FD9FF3','#FDB0F5','#FDC1F7','#FDACF4','#FEF1F9','#FFF0FF','#FFFFFF'];var divArray = ['aDiv','bDiv','cDiv'];var prev_banner = 0;var curr_banner = 0;var f = 0;  //tracks the text fadevar j = 0;//uncomment the following line if you want to use stop(also lines 40, 107-109)//var stop = false;function mkBG(toggle){//if(stop) return;if(toggle){  document.getElementById(divArray[prev_banner]).className = 'noShow';  document.getElementById(divArray[curr_banner]).className = 'yesShow';  }var banner = document.getElementById(divArray[curr_banner]);         banner.style.background = bgArray[j];  banner.style.color = fgArray[j];  j++;  if(j == bgArray.length && curr_banner == divArray.length - 1){    prev_banner = curr_banner;     curr_banner = 0;    j = 0;    setTimeout('fadeText()', 1500);    return;    }      else if(curr_banner < divArray.length && j == bgArray.length){    prev_banner = curr_banner;     curr_banner++;    j = 0;    setTimeout('fadeText()', 1500);    return;    }setTimeout('mkBG()', 25); }function fadeText(){var banner = document.getElementById(divArray[prev_banner]);         banner.style.color = fadeArray[f];  f++;  if(f == fadeArray.length){   f = 0;   setTimeout('mkBG(true)', 300);   }  else   setTimeout('fadeText()', 20);}function init(){document.getElementById('xDiv').className = 'noShow';setTimeout('mkBG(true)',50);}window.onload = init;</script>  </head><body> <p>  Customize your colors. </p> <div style="width:360px;">   <div class="yesShow" id="xDiv">   Your initialize message here..   </div>    <div class="noShow" id="aDiv" title="Google" onclick="window.location = 'http://www.google.com';">   This ticker message is for people who want to Google   </div>   <div class="noShow" id="bDiv" title="Yahoo" onclick="window.location = 'http://www.yahoo.com';">   This ticker message is for people who want to Yahoo   </div>   <div class="noShow" id="cDiv" title="Ask Mr. J" onclick="window.location = 'http://www.ask.com';">   This ticker message is for people who want to AskJeeves   </div> </div><!--<input type="button" value="stop" onclick="stop = true;">--></body></html>

    Let me know if it needs adjustments, and thanks to Jonas for the codebox tip.

  2. All is good. :) I can understand why you like the effects of your original script, a smoother transition I think.Drop a line please if you folks work out a formula that allows the same transition with a color incrementation(is that a word)? ..The project was a good exercise for me at any rate.And I'll leave a link to my latest attempt to imitate the original script.(With your parameters of course.)http://webfeet.siteburg.com/1colorBanner.htmlBe sure to hit the refresh or you could be working off of cache...

  3. Don't forget the '$' at the end of the regular expression, it's very important.Without it the string could 'end' with anything.You'll need to inspect the way you are calling the 'test' also, here's your fixes:

    <script type="text/javascript"><!-- hide javascript codevar justValidating = truefunction validateForm(form) //validate assessment data{  if (!validateStudentNumber(form.studentNum.value)) // student number valid?  {  form.studentNum.focus()  return false  }  if (justValidating) // only show alert box if validating, and not submitting  alert("Well Done: Your data is valid!") // all data validatedreturn true}function validateStudentNumber(studentNum){  var myRegexp = /^[A-Z]{2}\d{7}$/   if(!myRegexp.test(studentNum))   {    alert("Please enter two letters(Caps Please) before seven digits!")    return false   }return true}// end javascript hide --></script>

    Thanks,

  4. Almost everyone has their popup blocker on these days, I notice you're using the "get" method.If you have a pretty basic query string you might consider building the url and using'window.open()' like:

    window.open('http://www.google.com/search?hl=en&q=forms+popup+block&btnG=Google+Search','')

    One draw back is that you'll need to escape or encode the values if your query gets complicated or contains certain characters.http://www.w3schools.com/js/tryit.asp?file...ryjs_openwindowheehee, Just like the link on the above line :) Thanks,

  5. Would you like to use this, we can customize anything about it, because it's ours :) .

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head>  <title>Banner Colorizer</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  <style type="text/css">.noShow{ display: none;  width: 350px;   padding: 5px; }.yesShow{ display: block;  width: 350px;  cursor: pointer;  padding: 5px; }</style>  <script type="text/javascript">var bgArray = [['#06D5F9','#0A9DF5','#3587CA','#4173BE','#4D73B3'],['#FDEE37','#ECCB13','#DBB724','#C1A03E','#B0934F'],['#FDCFFE','#F9B7F9','#E659DB','#C00CB3','#A240A2']];var fgArray = [['#4D73B3','#4173BE','#3587CA','#0A9DF5','#06D5F9'],['#B0934F','#C1A03E','#DBB724','#ECCB13','#FDEE37'],['#A240A2','#C00CB3','#E659DB','#F9B7F9','#FDCFFE']];var divArray = ['aDiv','bDiv','cDiv'];var prev_banner = 0;var curr_banner = 0;var j = 0;var bTimer = null;var stop = false;function mkBG(toggle){if(stop) return;if(toggle){  document.getElementById(divArray[prev_banner]).className = 'noShow';  document.getElementById(divArray[curr_banner]).className = 'yesShow';  }banner = document.getElementById(divArray[curr_banner]);         banner.style.background = bgArray[curr_banner][j];  banner.style.color = fgArray[curr_banner][j];  j++;  if(j == bgArray[curr_banner].length && curr_banner == divArray.length - 1){    prev_banner = curr_banner;     curr_banner = 0;    j = 0;    setTimeout('mkBG(true)', 2000);    return;    }      else if(curr_banner < divArray.length && j == bgArray[curr_banner].length){    prev_banner = curr_banner;     curr_banner++;    j = 0;    setTimeout('mkBG(true)', 2000);    return;    }setTimeout('mkBG()', 200); }function init(){setTimeout('mkBG(true)',50);}window.onload = init;</script>  </head><body> <p>  Customize your colors. </p> <div style="width:360px; height: 40px;">    <div class="noShow" id="aDiv" title="Google" onclick="window.location = 'http://www.google.com';">   Google   </div>   <div class="noShow" id="bDiv" title="Yahoo" onclick="window.location = 'http://www.yahoo.com';">   Yahoo   </div>   <div class="noShow" id="cDiv" title="Ask Mr. J" onclick="window.location = 'http://www.ask.com';">   AskJeeves   </div> </div><input type="button" value="stop" onclick="stop = true;"></body></html>

    Left stop button on the page so you can check your colors.Thanks, :)

  6. You can use the form's element name as a string:http://javascriptkit.com/jsref/elements.shtmlLike:

    <script type="text/javascript">function MM_setRowValues(row, state){for ( i = 1; i <= 2; i ++ ){ var mField = "f" + row + i; document.forms['setCal'].elements[mField].selectedIndex = state;  }// end loop}// end function</script>  </head><body onload="MM_setRowValues(0, 1)"><form name="setCal"><table><tr>	<td>	<select name="f01">		<option value="">Pick One		<option value="c1">C1	</select>	</td>	<td>	<select name="f02">		<option value="">Pick One		<option value="c1">C1	</select>	</td></tr></table></form>

    Thanks,

  7. In JavaScript there is the built-in "toFixed()" that will provide a formatted decimal number.http://www.javascriptkit.com/javatutors/formatnumber.shtmlYou'll want to use parsefloat if the input is derived from a "text" input.

    <script type="text/javascript">function mkFixed(form){alert(parseFloat(form.elements['t1'].value).toFixed(2));return false;}</script></head><body><form onsubmit="return mkFixed(this)">Your Float: <input type="text" name="t1"><p><input type="submit" value="Format Number"></p></form>

    Thanks,

  8. You can use "new Option()" to add values to a select list.

    <script type="text/javascript">function addOption(objS, v){  if(v == '' || v != 'Add') return;  var slen = objS.options.length;  var temp = prompt('What is your favorite color?', 'Dark Blue');  if(!temp) return;  objS.options[slen] = new Option(temp, temp);  objS.selectedIndex = slen;}</script>  </head><body><form>Your Favorite Color: <select name="sel" onchange="addOption(this, this.value)"><option value="">Pick One<option value="Red">Red<option value="Blue">Blue<option value="Green">Green<option value="Add">Add Yours</select></form>

    Thanks,

  9. Here's an example for you, uses a regular expression:

    Title>Text box with capitals before numbers?Post>text box that the user has to enter two letters before digits
    <html><head><title>sharon5467 Field Checker</title><script type="text/javascript">function ckForm(form){var re = /^[A-Z]{2}\d+$/;      if(!re.test(form.elements['t1'].value)){      alert('Try Correct Format..');      return false;      }return true;}</script> </head><body><form onsubmit="return ckForm(this)"><input type="text" name="t1" size="10"><p><input type="submit"></p></form></body></html>

    Some links for you:http://www.w3schools.com/js/js_form_validation.asphttp://www.siteexperts.com/tips/functions/ts23/page3.aspDevMoPost back if you need any help.Thanks,

  10. That is cool. You could add a title if you wanted.

    <script type="text/javascript">function gothing(){var h=document.getElementById("test").value;var myTitle = prompt('Your Title Please..','Test Page');if(h.length!=0){var win=window.open("about:blank", "test");win.document.open();win.document.write('<html><head><title>\n' + myTitle + '</title></head><body>\n');win.document.write(h+"<br><br><input type='button' value='Close Window' onclick='window.close()'>")win.document.write('</body></html>');win.document.close();}else{alert("Error: 1a45f66d-'No Text Recieved'");}}</script>

    Thanks,

  11. Well, how about we check for 2 leading digits with a second regular expression?

    <script type="text/javascript">function ckField(){var errmsg = '';var IDPat =  /^[0-9]{1,3}[a-z]{1,2}[0-9]? \(exp: 407F\)| \(exp: 5JA\)| \(exp: 5JA1\)$/i;//test for 2 leading digitsvar _IDPatFail = /^[0-9]{2}[a-z]{1,2}/i;  if (!IDPat.test(document.OrderForm.a_Offer_ID.value) ||       _IDPatFail.test(document.OrderForm.a_Offer_ID.value)) {  errmsg = errmsg + "\n" + "Zonet Rebate OfferID format #AA (ie. 5JA)";  document.OrderForm.a_Offer_ID.focus();  alert (errmsg);  return false;  }return true;    }</script>

    Thanks,

×
×
  • Create New...