JavaScript - How To Link (input'range') To Css Style
Hi,
I am trying to link the <input type="range" min="450" max="800" value="500" /> to a CSS style for an AP box so when you move the slider it then changes the Css style (top:--px). allowing the Ap box to move with the slider. (important to work in Chrome) Here is the code: [CODE] <!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" /> <title>Untitled Document</title> <style type="text/css"> <!-- #apDiv1 { position:absolute; left:214px; top:34px; width:141px; height:164px; z-index:1; background-color:#3FF } --> </style> </head> <body> <div id="apDiv1"><p>have an image in here. Need to make this box move up and down with the slider.</p></div> <input type="range" min="450" max="800" value="500" /> </body> </html> [CODE] I have tried a number of way but can't get it, I am sure it is simple. Similar TutorialsIs it possible to do something like this: On a site there is a link that says "Darken Page". Upon clicking the link, the background color turns black. The link then changes to "Brighten things up" So just a style sheet switcher, but with one link and changes Thanks for any imput on this Hello everyone, I'm new to the programming world so please be kind I'm trying to find a code which would take the input value entered in a form field and on click direct you to a page which corresponds with what was entered. So for example: Enter "5" in field. Click Submit. Page opens up (which in fact would be an html file on my server called... 5.html) ( i would want to create 10 pages for values entered from 1-10... each value having a unique result when entered and clicked) I have no idea how to put this all together, i've been searching everywhere. Any kind of help would be appreciated. Hello there, I am having trouble with a javascript snippet that adds text to a textarea when you click on the link. Problem is that when you regularly type into the textarea, the links no longer add text. Here is the links: Code: <a href="javascript:insertText('<b></b> ','textIns');" onClick="void(0)">Bold</a> Here is the javascript Code: <script type="text/javascript"> function insertText(val,e) { document.getElementById(e).innerHTML+=val; } </script> Any ideas or suggestions? I wrote a function, to change a input value to show a key, which PHP later recognizes and makes addition changes too. However I can't seem to get this simple function to work, can you see anything wrong with it? Code: function quote(id) { var shout = document.getElementById('shout'); var currentShout = '; '.shout.value; var prefix = '@'.id; shout.value = prefix.currentShout; } I call it by Code: <a href="#" onclick="javascript: quote('2');">Comment</a> the input that changes is written as Code: <input id="shout" name="shout" type="text" onKeyPress="return submitenter(this,event);"> Hi all, I am working with a php code that I am trying to edit a bit. The last part I am trying to change I cannot figure out. Essentially I want to change the "Login" submit button to just a text link that says "Login" instead. Quote: <form action="<?php echo JRoute::_( 'index.php', true, $params->get('usesecure')); ?>" method="post" name="login" id="form-login" > <?php echo $params->get('pretext'); ?> <input id="modlgn_username" type="text" name="username" class="inputbox" alt="username" size="15" value="<?php echo JText::_('Username') ?>" onclick="login.username.value='';" /> <input id="modlgn_passwd" type="password" name="passwd" class="inputbox" size="15" alt="password" value="<?php echo JText::_('Password') ?>" onclick="login.passwd.value='';" /> <?php if(JPluginHelper::isEnabled('system', 'remember')) : ?> <label for="modlgn_remember"><?php echo JText::_('Remember me') ?></label> <input id="modlgn_remember" type="checkbox" name="remember" class="inputbox" value="yes" alt="Remember Me" /> <?php endif; ?> <input type="submit" name="Submit" class="button" value="<?php echo JText::_('LOGIN') ?>" /> <?php I am hoping this is just a minor change. Would someone mind showing me what I have to do? Thanks very much. I need the code for if the user enters in a code into the field for example E1 and clicks submit it'll redirect them to a certain form. And if another user entered in E2 it would redirect them to a DIFFERENT form. I hope this is the correct category of the site for me to post this. Wasn't sure if it should be here or PHP.
Hi all, Could someone explain the W3C DOM Range to me? Please note that I want to know how to do it with a standard W3C range, NOT an MSIE text range. Please don't simply point me to a web link ... I've seen all of those and I still don't get it. What I am trying to do is get a user's selection range (which I can already do), then modify it by adding information to the beginning and ending of the range. Specifically, I am trying to "wrap" a range with some extra text... like this: (1) This is a sentence written by the user. <- original (2) This is a sentence written by the user. <- user's selection (3) This is a [bbcode] sentence written [/bbcode] by the user. <- added text. note that the user's selection REMAINS SELECTED after the bbcode is added. What I need to know is how to add the information to the range. Do I change the range start and end points? Do I have to convert the text into an element (i.e. document.createElement('span')) before I insert it? Please explain to me how to use the DOM range... and do it in a "DOM range for dummies" manner, because I simply am not understanding what I see in web searches. Thanks! -- Roger I AM TRYING TO VALIDATE THE AGE RANGE SO THAT IT CAN ACCEPT AN AGE BETWEEN 16 - 99 BUT SOME HOW IM NOT GETTING THROUGH CAN ANYONE HELP ME WITH THAT PLEASE THANKS IN ADVANCE Code: <html> <head> <title>Registration</title> <script type="text/javascript"> function validation(form) { var invalid =" "; var minlength = 6; var emailchar =/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; var numchar =/(^\d+$)|(^\d+\.\d+$)/; var userName = registration.u_name.value; var firstName = registration.f_name.value; var lastName = registration.l_name.value; var yourage = registration.age.value; var pw1 = registration.pwd.value; var pw2 = registration.pwd1.value; var em_adss = registration.e_address.value; if (userName.length ==""){ alert("Please enter your USERNAME."); return false; } if ((userName.length < 5) || (userName.length > 15)) { alert("User name must be between 5 and 15 characters"); return false; } if (firstName.length ==""){ alert("Please enter your FIRSTNAME."); return false; } if (lastName.length ==""){ alert("Please enter your LASTNAME."); return false; } if (yourage.length ==""){ alert("Please enter your AGE."); return false; } if (! registration.age.value.match(numchar)){ alert ("Please enter a valid age."); return false; } if ((age < 16) && (age >99)){ alert ("Please enter and valid age range"); return false; } if (pw1 == '' || pw2==''){ alert ("Please enter password twice"); return false; } if (registration.pwd.value.length < minlength){ alert ("Your password must be at least" + minlength + "characters in length."); return false; } if (registration.pwd.value.indexOf (invalid) > -1) { alert("Spaces are not allowed in the password"); return false; } if (pw1 != pw2) { alert ("Your passwords didn't match. Please re-enter"); return false; } if (em_adss.length ==""){ alert("Please enter your EMAIL."); return false; } if (! registration.e_address.value.match(emailchar)){ alert("Stop playing games.\n Please enter a valid email address"); return false; } return true; } </script> </head> <body> <form name="registration" action="response.html" method="get" onSubmit="return validation(this);"> USERNAME:<br> Between 5-15 characters. <input name="u_name" type="text" size="35" maxlength="50"> <br><br> FIRSTNAME: <br> Enter your first name. <input name="f_name" type="text" size="35" maxlength="50"> <br><br> LASTNAME: <br> Enter your last name. <input name="l_name" type="text" size="35" maxlength="50"> <br><br> AGE: <br> Enter your age. (16-99) <input name="age" type="text" size="35" maxlength="50"> <br><br> PASSWORD: <br> Enter your password. <input name="pwd" type="password" size="35" maxlength="50"> <br><br> VERIFY PASSWORD: <br> Verify your password. <input name="pwd1" type="password" size="35" maxlength="50"> <br><br> EMAIL: <br> Enter your email address. <input name="e_address" type="text" size="35" maxlength="50"> <br><br> <input type="submit" value="Submit Information" name="submit"> <input name="reset" type="reset" value="Reset Information"> </form> </body> </html> Hi all, First of all, I am not a student and this is not homework. Secondly, I've been programming in C, Motorola assembler, Intel assembler and even GWBasic for years. I recently (this year) got into Web / Javascript / PHP / HTML programming and I'm clawing up the learning curve. I know a fair amount, but have a long way to go. OK here's my problem: I've been trying to integrate a WYSIWYG editor (TinyMCE) into a bulletin board software package (PHPBB3). All is working well except for one big stumbling block that I've been battling for the past MONTH!...: I want to support the original BBCode system of PHPBB3 (mostly because of the ability for the admin to add custom BBCodes). So, what I need to do is this: (1) Select a range of text. (2) Either REPLACE it with "[tag]selection[/tag]" or else INSERT "[tag]" before and "[/tag]" after. (3) Lastly, the original selection must remain selected so that additional BBCodes can be wrapped without the need to re-select. The purpose of (3) is, say, the user clicks "bold" and "italic" and "underline".... all they should have to do is click those 3, not re-select each time. I've tried doing this: (1) get the selection range (2) get the selection text (3) delete the range contents (4) create two "contextual fragments" (one for the opening tag, the other for the closing tag). (5) create a <span> element containing the selection text (6) Insert it all into the range with range.insertNode() (7) finally select the new span element This seems to work fine, but Internet Explorer fails (it complains when I try to get the selection range). I just don't know what I'm doing wrong... and worse I'm not even sure if I'm attacking the problem the proper way. Any ideas would be greatly appreciated! Thanks! -- Roger Hi, Is it possible in Javascript to verify a range of IP's for open port 80 and show as a hiperlink? The ideia is similar to ip scanners but it's for a web spider... Thanks Reply With Quote 01-11-2015, 01:04 PM #2 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts Not possible IMO. Javascript cannot access or interact with the operating system. All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit. if I have an html page that uses the <style> or a <link> to call a style sheet these properties aren't available to JavaScript is there a good way to access them? eg Code: <html> <head> <title>expandable text area</title> <style type="text/css"> #expandable{ height: 100px; } </style> </head> <body> <form> <textarea id="expandable" cols="30" rows="10"></textarea> </form> </body> <script type="text/javascript"> document.getElementById('expandable').addEventListener('click',function(){ if(!this.style.height){ this.style.height = this.scrollHeight+'px'; } alert(this.style.height); }, true); </script> </html> In this example I have the height set but I cannot access it since it is not declared in the style attribute of the html element Hi Guys, I am creating a 12 months events calendar and need javascript to compare a date range and apply a corresponding image banner once to the earliest instance of a particular date range eg: I want to have a banner image for the earliest date in the January to May date range and same for June to December (seperate image). The event dates get generated via a CMS using {event_start_date format="%F %j%S , %Y"} [APPLY JANUARY - MAY BANNER IMAGE] eg jm.jpeg January 3rd, 2011 Event 1 January 23, 2011 Event 2 Feb 24th,2011 Event 3 March 21st, 2011 Event 4 [APPLY JUNE - DEC BANNER IMAGE] eg jd.jpeg JUNE 30th, 2011 Event 5 September 12th, 2011 Event 6 [APPLY JANUARY - MAY BANNER IMAGE] eg jm.jpeg January 1st, 2012 Event 7 THANKS!!!!!!!!!! Hi I'm relatively new to Javascript and I'm trying to learn more about dates my problem is as follows I have to do validation on a form for 2 dates(StartDate and EndDate) the dates cannot be more than four months apart if they are an alert must be displayed. In other words Nov 2009 till March 2010 or May 2009 till September 2009 should be invalid regardless of the day of the month Simply 2 input boxes(StartDate and EndDate) and a submit I've got the other parts of my page worked out just this has me stumped I would appreciate any help in this regard Thank You for your time I want to validate two a date range using javascript, so that my program would check startdate less than end date. The below function only check the year, and it works. Code: function validate() { var start=document.entry.datum1.value; year = start.substr(0, 4); month = start.substr(5, 2); dayval = start.substr(8, 2); var end=document.entry.datum2.value; year1 = end.substr(0, 4); month1 = end.substr(5, 2); dayval1 = end.substr(8, 2); var myDate=new Date(); myDate.setFullYear(year,month,dayval); var today = new Date(); today.setFullYear(year1,month1,dayval1); if (myDate> today) { alert("The start date must come before the end date"); return false } return true; } But I have write a function for checking the whole date value and it didnt work. My date is in format- 2008-10-23(yyyy-mm-dd) Code: function validate() { var start=entry.datum1.value; year = start.substr(0, 4); month = start.substr(5, 2); dayval = start.substr(8, 2); intyear = parseInt(year, 10); intmonth = parseInt(month, 10); intdayval = parseInt(dayval, 10); var end=entry.datum2.value; year1 = end.substr(0, 4); month1 = end.substr(5, 2); dayval1 = end.substr(8, 2); intyear1 = parseInt(year1, 10); intmonth1 = parseInt(month1, 10); intdayval1 = parseInt(dayval1, 10); var startDate = Date.parse(intyear,intdayval,intmonth); var endDate = Date.parse(intyear1,intdayval1,intmonth1); if (startDate > endDate) { alert("The start date must come before the end date"); return false; } return true; } Please help Hi, i have a problem to validate time range in javascript. i've search in the website and found some example. below is the my coding Code: function timeCheck(){ branchCode = <%=sessionUser.getBranchCode()%>; var d = new Date(); var curr_hour = d.getHours(); var curr_min = d.getMinutes(); if (curr_min < 10){ curr_min = "0" + curr_min } var currtime = curr_hour + ":" + curr_min; if(branchCode >= 1 && branchCode <= 5){ st = "7:30"; et = "9:00"; } else if(branchCode >= 6 && branchCode <= 10){ st = "9:01"; et = "10:30"; } else if(branchCode >= 11 && branchCode <= 15){ st = "10:31"; et = "12:00"; } else if(branchCode >= 16 && branchCode <= 20){ st = "12:01"; et = "13:30"; } else if(branchCode >= 21 && branchCode <= 26){ st = "13:31"; et = "15:00"; } else if(branchCode >= 27 && branchCode <= 31){ st = "15:01"; et = "16:30"; } else if(branchCode >= 32 && branchCode <= 71){ st = "16:31"; et = "18:00"; } else { st = "6:30"; et = "19:00"; } if(validate_time(currtime,st,et)){ alert("Cannot access this page"); location.href='<%=request.getContextPath()%>/security/welcome.do'; } } function validate_time(currtime,st,et ){ currtime = currtime.split(/:/); st = st.split(/:/); et = et.split(/:/); return ( currtime[0] < st[0] || currtime[0] > et[0] || (currtime[0] == st[0] && currtime[1] < st[1]) || (currtime[0] == et[0] && currtime[1] > et[1]) ); //return TRUE if time not in range } i want to control user's access to the page. they can only access within the range given. example: current time = 10:14 st = 9:01 et = 10:30 When I test, the currtime[0] < st[0] return true. I don't understand why the statement return true. can someone help me? Thanks in advance. Hi all, can someone help me what is the right syntax to use for field that carry hidden value same as autoincrement value in db. The form was able to add n delete this value from db make it the hidden value keep changing. it is possible to check range validation for the value? in this case the hidden value is sid. How to correct the line below? --> var chkVal = theForm.("score1"&&sid).value the full script as below. <script> function Form1_Validator(theForm) { // require that the To Field be greater than or equal to the From Field var chkVal = theForm.("score1"&&sid).value var chkVal2 = theForm.("score2"&&sid).value if (chkVal != "" && !(chkVal >= chkVal2)){ alert("The \"Score Range 2\" value must be greater than the \"Score Range 1\" value."); theForm.("score2"&&sid).focus(); return (false); } } </script> Hi all, can someone help me what is the right syntax to use for field that carry hidden value same as autoincrement value in db. The form was able to add n delete this value from db make it the hidden value keep changing. it is possible to check range validation for the value? in this case the hidden value is sid. How to correct the line below? --> var chkVal = theForm.("score1"&&sid).value the full script as below. <script> function Form1_Validator(theForm) { // require that the To Field be greater than or equal to the From Field var chkVal = theForm.("score1"&&sid).value var chkVal2 = theForm.("score2"&&sid).value if (chkVal != "" && !(chkVal >= chkVal2)){ alert("The \"Score Range 2\" value must be greater than the \"Score Range 1\" value."); theForm.("score2"&&sid).focus(); return (false); } } </script> Hi all, can someone help me what is the right syntax to use for field that carry hidden value same as autoincrement value in db. The form was able to add n delete this value from db make it the hidden value keep changing. it is possible to check range validation for the value? in this case the hidden value is sid. How to correct the line below? --> var chkVal = theForm.("score1"&&sid).value the full script as below. <script> function Form1_Validator(theForm) { // require that the To Field be greater than or equal to the From Field var chkVal = theForm.("score1"&&sid).value var chkVal2 = theForm.("score2"&&sid).value if (chkVal != "" && !(chkVal >= chkVal2)){ alert("The \"Score Range 2\" value must be greater than the \"Score Range 1\" value."); theForm.("score2"&&sid).focus(); return (false); } } </script> Hi all, I am trying to wrap a text selection with BBCode. I have it working, but there is one final part I need help with. First, here's the code I'm using: Code: var range = ed.selection.getRng(true); var s = ed.dom.create('span', {}, ''); range.surroundContents(s); s.innerHTML = open + s.innerHTML + close; ed.selection.select(s); This is an explanation of each line: get the user's selection as a W3C compatible range create an empty <span> element surround the selection range with the span convert the selection from "selection" to "[bbcode]selection[/bbcode]" by using innerHTML select the new <span> element Of course, selecting the span ALSO selects the BBCode open and close tag... like in this pictu So, the last thing I need to do (the whole point of this post)... how do I MOVE the range start and end points so that only the selection is selected and NOT the whole thing? I will greatly appreciate if someone can tell me how to move those selection start and end points... Thanks! -- Roger Hello, First I would like to say I am not a coder. I would like to have a specific date range in years entered into a text box and if anything else is entered a pop up alert would appear. The date range would be from 1912 to 2002. Any help with this would be greatly appreciated. I am using Joomla 2.5 and a form constructor called RS Form Pro That allows JS to be used. This is the Javascript I am trying to use: Code: <script type="text/javascript"> function checkDate(theForm) year=document.getElementById('YearBorn').value; if(year<1912 || year>2002) { alert("registration is restricted to those born between 1912 to 2002"); return false; else { return true; } } </script> This is how I am trying to call it Code: onblur="return checkDate(this);" I am not sure if I am calling it correctly or if the JS code is even correct. When the user enters the date and it is not within the date range I need the alert to pop up. Thank you for any help you can provide DeZiner |