Page 6 of 6 FirstFirst ... 456
Results 51 to 60 of 60

Thread: JavaScript Validation?

  1. #51
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    PLEASE!!!!

  2. #52
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Can we see the entire script?
    - Mike

  3. #53
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    Huh? The whole thing's not in Attachment 878? What's it missing?
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

  4. #54
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!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>
    <title>Time:</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript">
    function displayText() {
    	var text = document.getElementById("myText");
    	text.style.visibility=(document.forms['myForm'].options.checked) ? "visible" : "hidden";
    }
    
    function displayDay() {
    	var day = document.getElementById("showDay");
    	day.style.visibility=(document.getElementById('dy').checked) ? "visible" : "hidden";
    }
    	
    function displayMonth() {
    	var month = document.getElementById("showMonth");
    	month.style.visibility=(document.getElementById("mon").checked) ? "visible" : "hidden";
    }
    
    function displayDate() {
    	var date = document.getElementById("showDate");
    	date.style.visibility=(document.getElementById('dt').checked) ? "visible" : "hidden";
    }
    
    function displayYear() {
    	var year = document.getElementById("showYear");
    	year.style.visibility=(document.getElementById('yr').checked) ? "visible" : "hidden";
    }
    
    function displayHour() {
    	var hour = document.getElementById("showHour");
    	hour.style.visibility=(document.getElementById('hr').checked) ? "visible" : "hidden";
    }
    
    function displayMinute() {
    	var minute = document.getElementById("showMinute");
    	minute.style.visibility=(document.getElementById('mn').checked) ? "visible" : "hidden";
    }
    
    function displaySecond() {
    	var second = document.getElementById("showSecond");
    	second.style.visibility=(document.getElementById('sec').checked) ? "visible" : "hidden";
    }
    
    function displayMillisecond() {
    	var millisecond = document.getElementById("showMillisecond");
    	millisecond.style.visibility=(document.getElementById('ms.checked').checked) ? "visible" : "hidden";
    }
    </script>
    </head>
    
    <body>
    <span id="showDay">Sunday, </span><span id="showMonth">January </span><span id="showDate">1, </span><span id="showYear">0 </span><span id="showHour">12</span><span id="showMinute">:00</span><span id="showSecond">:00</span><span id="showMillisecond">.0</span><br />
    <form id="myForm"><input name="options" type="checkbox" onClick="displayText();" />Options<br /></form>
    <div id="myText"><form id="myForm2"><input name="dy" type="checkbox" onClick="displayDay();" />Day<br />
    <input name="mon" type="checkbox" onClick="displayMonth();" />Month<br />
    <input name="dt" type="checkbox" onClick="displayDate();" />Date<br />
    <input name="yr" type="checkbox" onClick="displayYear();" />Year<br />
    <input name="hr" type="checkbox" onClick="displayHour();" />Hour<br />
    <input name="mn" type="checkbox" onClick="displayMinute();" />Minute<br />
    <input name="sec" type="checkbox" onClick="displaySecond();" />Second<br />
    <input name="ms" type="checkbox" onClick="displayMillisecond();" />Millisecond</form></div>
    <script type="text/javascript">
    var get = new Date();
    var oldday = get.getDay();
    var newday = [
        "Sunday",
        "Monday",
        "Tuesday",
        "Wednesday",
        "Thursday",
        "Friday",
        "Saturday"
      ][oldday];
    
    var oldmonth = get.getMonth();
    var newmonth = [
        "January",
        "February",
        "March",
        "April",
        "May",
        "June",
        "July",
        "August",
        "September",
        "October",
        "November",
        "December"
      ][oldmonth];
    
    var getdate = get.getDate();
    var getyear = get.getFullYear();
    var oldhour = get.getHours();
    var newhour;
    
    if (oldhour >= 12) {
    	newhour = oldhour -= 12;
    }
    else {
    	newhour = oldhour;
    }
    
    var oldminute = get.getMinutes();
    var newminute;
    
    if (oldminute <= 10) {
    	newminute = "0" + oldminute;
    }
    else {
    	newminute = oldminute;
    }
    
    var getsecond = get.getSeconds();
    var getmillisecond = get.getMilliseconds();
    
    function update() {
    	var writeday = newday;
    	document.getElementById("showDay").firstChild.nodeValue = writeday;
    	var writemonth = newmonth;
    	document.getElementById("showMonth").firstChild.nodeValue = writemonth;
    	var writedate = getdate;
    	document.getElementById("showDate").firstChild.nodeValue = writedate;
    	var writeyear = getyear;
    	document.getElementById("showYear").firstChild.nodeValue = writeyear;
    	var writehour = newhour;
    	document.getElementById("showHour").firstChild.nodeValue = writehour;
    	var writeminute = newminute;
    	document.getElementById("showMinute").firstChild.nodeValue = writeminute;
    	var writesecond = getsecond;
    	document.getElementById("showSecond").firstChild.nodeValue = writesecond;
    	var writemillisecond = getmillisecond;
    	document.getElementById("showMillisecond").firstChild.nodeValue = writemillisecond;
    }
    
    setInterval(update, 1);
    update();
    
    </script>
    </body>
    </html>
    - Mike

  5. #55
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    So, what was the problem?
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

  6. #56
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    You referenced each item with document.form, when they weren't even inside a form element. You had to use document.getElementById().
    - Mike

  7. #57
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    Yes they were. The milliseconds button doesn't work and it doesn't have the date and time.
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

  8. #58
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default 13 months...

    Yeah, yeah, I know, 13 months, but...
    Code:
    var width = 100;
    var unit = "percent";
    // 'width' is the width, in pixels or a percentage of the entire width of the browser window.
    // 'unit' is the unit used in width -- its possible values are:
    // 	pixels
    // 	percent
    
    var align = "center";
    // The alignment of the rule. Possible values are:
    // 	left
    // 	center
    // 	right
    // Center is recommended to best simulate the XP startmenu dividers.
    
    /*
    Windows XP Horizontal Rule
    by techno_race
    http://www.dynamicdrive.com
    */
    
    var fail = "Error, please check coding.";
    var style1 = 'bgcolor="#D3D3C8" style="background-color: #D3D3C8;"';
    var style2 = 'bgcolor="#FEFEFE" style="background-color: #FEFEFE;"';
    
    if (unit == "pixels") {
    	var prepixelsnc = unit - 33;
    	if (prepixelsnc <= 0) {
    		var pixelsnc = 1;
    	}
    	if (prepixels > 0) {
    		var pixelsnc = prepixelsnc;
    	}
    	var fullnc = pixelsnc + 33;
    }
    
    if (align == "center") {
    	if (unit == pixels) {
    		var prepixels = unit - 66;
    		if (prepixels <= 0) {
    			var pixels = 1;
    		}
    		if (prepixels > 0) {
    			var pixels = prepixels;
    		}
    		var full = pixels + 66;
    		document.write('<table align="center" border="0" cellspacing="0" cellpadding="0"><tr><td width="33" height="1"><img src="lt.png" width="33" height="1"></td><td width="' + pixels + '" height="1" ' + style1 + '></td><td width="33" height="1"><img src="rt.png" width="33" height="1"></td></tr><tr><td width="33" height="1"><img src="lb.png" width="33" height="1"></td><td width="' + pixels + '" height="1" ' + style2 + '></td><td width="33" height="1"><img src="rb.png" width="33" height="1"></td></tr></table>');
    	}
    	if (unit == "percent") {
    		document.write('<table align="center" width="' + unit + '%" border="0" cellspacing="0" cellpadding="0"><tr><td width="33" height="1"><img src="lt.png" width="33" height="1"></td><td height="1" ' + style2 + '></td><td width="33" height="1"><img src="rt.png" width="33" height="1"></td></tr><tr><td width="33" height="1"><img src="lb.png" width="33" height="1"></td><td height="1" ' + style2 + '></td><td width="33" height="1"><img src="rb.png" width="33" height="1"></td></tr></table>');
    	}
    }
    if (align == "left") {
    	if (unit == "pixels") {
    		document.write('<table align="left" width="' + fullnc + '" border="0" cellspacing="0" cellpadding="0"><tr><td width="' + pixelsnc + '" height="1" ' + style1 + '></td><td width="33" height="1"><img src="rt.png" width="33" height="1"></td></tr><tr><td width="' + pixels + '" height="1" ' + style2 + '></td><td width="33" height="1"><img src="rb.png" width="33" height="1"></td></tr></table>');
    	}
    	if (unit == "percent") {
    		document.write('<table align="left" width="' + unit + '%" border="0" cellspacing="0" cellpadding="0"><tr><td height="1" ' + style1 + '></td><td width="33" height="1"><img src="rt.png" width="33" height="1"></td></tr><tr><td height="1" ' + style2 + '></td><td width="33" height="1"><img src="rb.png" width="33" height="1"></td></tr></table>');
    	}
    }
    if (align == "right") {
    	if (unit == "pixels") {
    		document.write('<table align="right" width="' + fullnc + '" border="0" cellspacing="0" cellpadding="0"><tr><td width="33" height="1"><img src="lt.png" width="33" height="1"></td><td width="' + pixelsnc + '" height="1" ' + style1 + '></td></tr><tr><td width="33" height="1"><img src="lb.png" width="33" height="1"></td><td width="' + pixels + '" height="1" ' + style2 + '></td></tr></table>');
    	}
    	if (unit == "percent") {
    		document.write('<table align="right" width="' + unit + '%" border="0" cellspacing="0" cellpadding="0"><tr><td width="33" height="1"><img src="lt.png" width="33" height="1"></td><td height="1" ' + style1 + '></td></tr><tr><td width="33" height="1"><img src="lb.png" width="33" height="1"></td><td height="1" ' + style2 + '></td></tr></table>');
    	}
    }
    else {
    	document.write(fail);
    }
    This is a bit edited. The entire script is in the attached archive. Can it also be used multiple times on one page?
    Last edited by techno_race; 06-22-2008 at 02:18 PM. Reason: From May '07 to June '08 is 13 months. Not 6.
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

  9. #59
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    Quote Originally Posted by tech_support View Post
    Nope. AJAX sends data from one page to another without refreshing the page.
    I can't believe I never replied to that. So, it is related to PHP, it sends data from one page to the other without refreshing the page, and PHP sends data from one page to the other with refreshing the page.
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

  10. #60
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Could be done with any other language, like ASP.net
    ....and why reply now? A bit late?
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •