JavaScript - Button Date Insert
Hi all, very new to Javascript, been searching the net for a simple script which has a text box with a button beside and when the visitor clicks the button the date is enter in to the text box automaticly.
Easy, I guess if you know how. Thanks Similar TutorialsHi to All, I have this problem: I' dl ike that, if one clicks a button, appear window_explorer in which it' s possible to choose an image that it will put in the specific td of the table. <head> <script> function add_pic() { document.forms[0].pic.value == code to choose image ... } </script> </head> <body> <form method="POST" name="FrontPage_Form1"> ... <table> <tr><td><button onClick="add_pic()">Insert Statitistic map</button></td></tr> <tr><td>Comments</td></tr> <tr><td id="pic" name="pic"> PLACE IN WHICH IMAGE APPEAR </td></tr> </table> ... </body> Thanks in advance !!! P.S. I use IE6 and Windows XP Hi, I have 31 audio files and want to play one each day from a single html button. I have the audio files in the same directory as the html page. I have tried to adapt some code to do this, but have not had success. Any help would be much appreciated! Here is what I have so far: Code: <body> <button id="button" onclick=" " return false">Play</button> </body> <script type="text/javascript"> var currentDay = (new Date()).getDate(); document.getElementById('button').onclick = "proverbs" + currentDay + ".mp4" ; </script> Not sure if this is possible in javascript: I'm looking for two different dates (bill date and due date) on an invoice that are captured by OCR. If one of them exists, but the other does not, I want the empty field to be 14 days before (or after) the other. For example: if the bill date is 7/27/2010 and the due date was not captured, I want to set the due date as 8/10/2010 (14 days after the bill date). If the due date was captured as 8/10/2010, but the due date is blank, I want to assign the bill date as 7/27/2010 (14 days before the due date). if both dates have values, do nothing. Thanks. Using Adobe Form Javascript validation, how would I do this code for Visual Basic in Javascript (non web) Code: If PurchaseDate.Value > Date Then MsgBox ("PurchaseDate cannot be greater than Today's Date!") Cancel = True End If Something along these lines but this isnt working: Code: If (PurchaseDate.Value > Date) Then { app.alert ("Purchase Date cannot be greater than Today's Date!"); } Thanks Hi, I've inherited a Form which calculates a future date based on a calculation and then inserts today's date and the future date into a database. The day part of the date is formatted as a number. This is fine, but up to 9 the numbers display in single figures with no leading zeros. I want them to display leading zeros (e.g. 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11... 30, 31) So; 1/12/2010 is NOT wanted 01/12/2010 IS wanted The inherited code originally set the Month names as "Jan", "Feb" etc, and it was easy to kludge these to 01, 02... 12, but I suspect there's a more elgant solution to this as well, this bit of the code works so it's not as vital to neaten this but my database needs dd/mm/yyyy format (it's a third party email program). Code: </script> <script type="text/javascript"> var todaysDate = new Date(); function updateExpiryDate(){ var weeklyMileage = document.getElementById('AvWeeklyMileage').value; var expiryDate; var weeks = 0; var expiryDateString = ''; if (!isNaN(parseInt(weeklyMileage))){ weeks = 700/weeklyMileage; expiryDate = new Date(todaysDate.getTime() + (1000 * 3600 * 24 * 7 * weeks)); var expiryDateString = expiryDate.getDate() + '/' + getMonthString(expiryDate.getMonth()+1) + '/' + expiryDate.getFullYear(); document.getElementById('expiryDate').innerHTML = expiryDateString; document.getElementById('ShoeExpiryDate').value = expiryDateString; } else { document.getElementById('ShoeExpiryDate').value = ''; document.getElementById('expiryDate').innerHTML = 'Please enter a valid weekly average mileage' } } function getMonthString(monthNumber){ var monthString = ""; switch(monthNumber){ case 1: monthString = "01"; break; case 2: monthString = "02"; break; case 3: monthString = "03"; break; case 4: monthString = "04"; break; case 5: monthString = "05"; break; case 6: monthString = "06"; break; case 7: monthString = "07"; break; case 8: monthString = "08"; break; case 9: monthString = "09"; break; case 10: monthString = "10"; break; case 11: monthString = "11"; break; case 12: monthString = "12"; break; default: // do nothing; } return monthString; } function setTodaysDate(){ var todaysDateString = todaysDate.getDate() + '/' + getMonthString(todaysDate.getMonth()+1) + '/' + todaysDate.getFullYear(); document.getElementById('todaysDate').innerHTML =todaysDateString; document.getElementById('DateOfPurchase').value = todaysDateString; } Can someone point me in the right direction please? Hi, I need to add days to a date in javascript, My requirement is as follows: Date is coming from a textbox. eg:- 26/07/2010 days from this statement var day1=document.getElementById('<%=HiddenDate.ClientID %>').value; an eg:- if the date is 28/01/2012 and days Needed to be added=5 the added date should be 02/02/2012. Can anybody help me? Thanks Jamuna Hello, I really need your help with one. How can I use the following code below to save the date from my popup window datepicker back into a var and relay it back onto its parent page? I can't seem to figure this out: Code: <html> <head> <script> function open_cal() { var str_html = "" + "<!DOCTYPE html>\n" + "<html lang=\"en\">\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>CALENDAR</title>\n" + "<link href=\"jq/jquery-ui.css\" rel=\"stylesheet\" type=\"text/css\">\n" + "<script src=\"jq/jquery.min.js\" type=\"text/javascript\"></" + "script>\n" + "<script src=\"jq/jquery-ui.min.js\" type=\"text/javascript\"></" + "script>\n" + "<script src=\"jq/datepicker.js\" type=\"text/javascript\"></" + "script>\n" + "</head>\n" + "<body>\n" + "<div id=\"text\" style=\"font: bold 10pt Tahoma\">Enter Approval Date:</div>\n" + "<div id=\"datepicker\"></div>\n" + "</body>\n" + "</html>" var j = window.open("","CALENDAR","width=200,height=250,status=no,resizable=yes,top=200,left=200") j.opener = self; j.document.write(str_html); } </script> </head> <body> <input onclick="open_cal()" type="button" value="Open" name="B1"> </body> </html> Datepicker.js: Code: $(function() { $( "#datepicker" ).datepicker({ dateFormat: 'dd/mm/yy', onSelect: function(dateText, inst) { alert(dateText) window.close() } }) }); Any help with this is greatly and mostly appreciated. Thanks in advance, Cheers, J I have a drop down menu where people can select a month, day and year. Based on their selection, I want to show them an image. If their selection is >= July 26, 2010 but <= July 25, 2011, show the red image; If their selection is >= July 26, 2011 but <= July 25, 2012, show the white image; If their selection is >= July 26, 2012 but <= July 25, 2013, show the blue image; If their selection is >= July 26, 2013 but <= July 25, 2014, show the yellow image; I don't know how to compare a selected date to a range of dates like this. hello there this is in vb script. but i dont where to post it. can any one hlep me out plzz I need to check if the date entered by user is within 5th date from current date. I am trying to do it this way entered date has month and date value Code: sResvDate = 01/24 Set sMaxDays to getdate(5) but get date will give year too. and how do i compare if it less than 5th day or not. Hi folks, i am trying to generate a dynamic datefield with date mask "mm/dd/yyyy" and trying to insert it into Oracle db ...i still got the error ORA invalid month ehich means the date filed is not recognized as date: below is what i am doing : newStartDate = document.createElement( 'INPUT' ); newStartDate.setAttribute('type','Date'); newStartDate.setAttribute('id1','id'+ elementid+elementrow); newStartDate.setAttribute('name','StartDateName'+ elementid+elementrow); newStartDate.size=8; newStartDate.style.backgroundColor= bgc; any help thanks ?? Also i want to add a datepicke to this textbox..how it is posible / other option is to use Jquery datepicker but could not know how to impement it thanks again Hey guys. This is vague because I dont know what exactly to tell you but please reply with me so I can fix this. I want to add something to my forum. Specifically, I want to add a HTML and Picture button for when you go to reply. Like posting an article here, there are also these options (font, alignment, insert image) I do not know how to achieve this but shouldnt be too hard. Here are the two sources you will need to look through to help me fix the forum. http://neoweather.com/FWFORUM.JS http://static.websimages.com/JS/fw.js THANKS Hey guys. I want to add something to my forum. Specifically, I want to add a HTML and Picture button for when you go to reply. Like posting an article here, there are also these options (font, alignment, insert image) I do not know how to achieve this but shouldnt be too hard. Here are the two sources you will need to look through to help me fix the forum. http://neoweather.com/FWFORUM.JS http://static.websimages.com/JS/fw.js THANKS i'm still a relative noob and this has me stuck - i have a save button with a "save as copy" in the save dropdown list. add new item directs to a premade/formatted project that is used as a template, so on that item i only want/need the "save as copy" but on all other items that use the form i need to only have the "save" function. is there any way to either change the function of the button depending on item that is being viewed in the edit screen OR hide the "save" button and only show the button associated with "save as copy - and vis versa for the rest of the items?? current button code is - protected function getToolbar() { $options = array(); $user = JFactory::getUser(); $create_ms = $user->authorise('core.create', 'com_pfmilestones'); $create_task = $user->authorise('core.create', 'com_pftasks'); $options[] = array( 'text' => 'JSAVE', 'task' => $this->getName() . '.save'); $options[] = array( 'text' => 'Save as new project', 'task' => $this->getName() . '.save2copy', 'options' => array('access' => ($this->item->id > 0))); PFToolbar::dropdownButton($options, array('icon' => 'icon-white icon-ok')); item used as template is id=8 any help or suggestions would be greatly appreciated.. Hi, I am not entirely sure what I am doing wrong here, and I have been looking at this for ages, so apologies in advance if I have become so bleary eyed I can't see something simple. I use php to create buttons based on values pulled for a table. The problem I have is when you click on the first button the javascript function works great, when you click on the next button you get the same output even though it should be different results. I am working in ff and I can see on my firebug console that the javascript function is being called, but it is not passing the new value of the second or third button, it just keeps repassing the value of the first button. So not entirely sure where I am going wrong here. My page is: Code: <script type="text/javascript"> function loadXMLDoc2(File,ID,Msg){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; } } var params=Msg; xmlhttp.open("POST",File,true); xmlhttp.setRequestHeader("Pragma", "Cache-Control:no-cache"); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(params); } </script> <head> <body> <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); $result = mysql_query("SELECT DISTINCT theme FROM goods WHERE category='{$_POST['category']}' ORDER BY theme DESC"); while($row = mysql_fetch_array($result)){ echo '<input type="text" class="hidden" name="theme" id="theme" value="' . $row['theme'] . '" ><input type="button" class="button3" name="product" id="product" value="' . $row['product'] . '" onClick="loadXMLDoc2(\'getShow.php\',\'txtHint\',\'theme=\'+encodeURI(document.getElementById(\'rtheme\').value))" > '; } echo '<br /><br /> <div id="txtHint"><div> <br /> <br />'; mysql_close($con); ?> And getShow.php produces a table with a list of product images, names and prices, based on theme. So basically not sure where I am going wrong here? i got javascripts button : Code: <input type="button" value="select" onClick="document.getElementById('input').select()" /> how can i transform "button" to image button (gif) I have 4 rows in a table. Each row consist of 4 radio buttons. Each radio button per row has different values in it but has the same name (group) ex: <input type="radio" name="a" value="1"> <input type="radio" name="a" value="2"> <input type="radio" name="a" value="3"> <input type="radio" name="a" value="4"> <input type="radio" name="b" value="1"> <input type="radio" name="b" value="2"> <input type="radio" name="b" value="3"> <input type="radio" name="b" value="4"> and so on.. If I click radio button A with value 2, I want to output the total at the bottom as "2".. Also, if I click radio button B with value 3, I want to output the total of A and B as 5 and so on.. How can I automatically calculate the answer based on which radio button was click? update: I got my answer from this site: http://stackoverflow.com/questions/1...s-using-jquery I am delving into the coding world and while I understand the basic principle of cookies, conditional statements, arrays, etc... I am still learning how to properly implement them. Any asistance with the following situation would be greatly appreciated and help with my learning as I try to reverse engineer the logic. I have looked around the web and this forum with little success. If the situation below is too complicated, I would really appreciate even a shove in the right direction regarding the logic. ----------------- How could I show a preset counter which counts up from a preset, beginning number toward a preset, end number? I imagine the increment and speed is set be the difference between the two numbers and a timeframe. Assumptions: I would rather not set the increment but edit the end number to show a steady increase. As I update that number, the increment adapts dynamically. I would want the number/script to be useful, so it should not refresh to the beginning number on each page load (i.e. num=0). When a visitor comes to the page, it must seem like the counter has been steadily been increasing in their absence. Coke or Pesi did something similar one time regarding cans sold to date (doubt it was plugged into a DB somewhere but rather based on a steady sales figure) and it was pretty cool. All the best! Hi I am working on PHP/javascript development. I want to insert a span code into DB how can i do? here is the code: Code: <html> <head> <script type="text/javascript"> var xScroll, yScroll, timerPoll, timerRedirect, timerClock; function initRedirect(){ if (typeof document.body.scrollTop != "undefined"){ //IE,NS7,Moz xScroll = document.body.scrollLeft; yScroll = document.body.scrollTop; clearInterval(timerPoll); //stop polling scroll move clearInterval(timerRedirect); //stop timed redirect timerPoll = setInterval("pollActivity()",1); //poll scrolling //timerRedirect = setInterval("mySubmit()",100000); //set timed redirect //timerRedirect = setInterval("mySubmit()",100000); //set timed redirect timerRedirect = setTimeout("mySubmit()",60000); //for tracking only clearInterval(timerClock); document.getElementById("clock").innerHTML="0"; timerClock=setInterval("document.getElementById('clock').innerHTML=parseInt(document.getElementById('clock').innerHTML,10)+1",1000); //end tracking } else if (typeof window.pageYOffset != "undefined"){ //other browsers that support pageYOffset/pageXOffset instead xScroll = window.pageXOffset; yScroll = window.pageYOffset; clearInterval(timerPoll); //stop polling scroll move clearInterval(timerRedirect); //stop timed redirect timerPoll = setInterval("pollActivity()",1); //poll scrolling // timerRedirect = setInterval("location.href='newtask_process.php'",100000); //set timed redirect // timerRedirect = setInterval("mySubmit()",100000); //set timed redirect timerRedirect = setTimeout("mySubmit()",60000); //for tracking only clearInterval(timerClock); document.getElementById("clock").innerHTML="0"; timerClock=setInterval("document.getElementById('clock').innerHTML=parseInt(document.getElementById('clock').innerHTML,10)+1",1000); //end tracking } //else do nothing } function mySubmit() { document.forms.formdesc.submit2.click(); } function pollActivity(){ if ((typeof document.body.scrollTop != "undefined" && (xScroll!=document.body.scrollLeft || yScroll!=document.body.scrollTop)) //IE/NS7/Moz || (typeof window.pageYOffset != "undefined" && (xScroll!=window.pageXOffset || yScroll!=window.pageYOffset))) { //other browsers initRedirect(); //reset polling scroll position } } document.onmouseout=initRedirect; document.onmousemove=initRedirect; document.onclick=initRedirect; document.onkeydown=initRedirect; window.onload=initRedirect; window.onresize=initRedirect; </script> </head> <body> Time: <span id="clock" style="font-weight:bold">0</span> </body> </html> I can see the clock on a page but i want to insert into DB. How can I do that?? My javascript knowledge is -10 out of 10. could someone please show me where to insert this javascript command in my header.php file? Code: <script type="text/javascript"> $('#query').autocomplete({ serviceUrl:'service/autocomplete.ashx', minChars:2, delimiter: /(,|;)\s*/, // regex or character maxHeight:400, width:300, deferRequestBy: 0, //miliseconds params: { country:'Yes' }, //aditional parameters // callback function: onSelect: function(value, data){ alert('You selected: ' + value + ', ' + data); }, // local autosugest options: lookup: ['January', 'February', 'March', 'April', 'May'] //local lookup values }); </script> HEADER.PHP file Code: <?php $timing_start = explode(' ', microtime()); if($PMDR->get('header_file')) { $header = $PMDR->getNew('Template',PMDROOT.TEMPLATE_PATH.'/'.$PMDR->get('header_file')); } else { $header = $PMDR->getNew('Template',PMDROOT.TEMPLATE_PATH.'/header.tpl'); } // Check for maintenance option and show header message bar if necesarry if($PMDR->getConfig('maintenance') AND in_array('admin_login',$_SESSION['admin_permissions'])) { $header->set('maintenance',true); } if($PMDR->getConfig('usershare') == 'FacebookConnect') { $header->set('facebook',true); } if($PMDR->get('meta_description')) { $header->set('meta_description',strip_tags($PMDR->get('meta_description'))); } else { $header->set('meta_description',$PMDR->getConfig('meta_description_default')); } if($PMDR->get('meta_keywords')) { $header->set('meta_keywords',$PMDR->get('meta_keywords')); } else { $header->set('meta_keywords',$PMDR->getConfig('meta_keywords_default')); } if($PMDR->getConfig('search_display_all') OR on_page('index.php')) { $header->set('searchform',$searchform); $header->set('search_display_all',($PMDR->getConfig('search_display_all') OR on_page('index.php'))); } $PMDR->loadJavascript($PMDR->getConfig('head_javascript')); $PMDR->loadJavascript('<script type="text/javascript" src="'.BASE_URL.'/includes/javascript_global.js"></script>'); $PMDR->loadJavascript('<script type="text/javascript" src="'.BASE_URL.TEMPLATE_PATH.'jquery.autocomplete.js"></script>'); $PMDR->loadJavascript('<script type="text/javascript" src="'.BASE_URL.TEMPLATE_PATH.'jquery.js"></script>'); $PMDR->loadJavascript('<script type="text/javascript" src="'.BASE_URL.TEMPLATE_PATH.'jquery.jqtransform.js"></script>'); //if(is_object($xajax)) $javascript .= $xajax->getJavascript(BASE_URL.'/includes/xajax/'); $PMDR->setAdd('javascript_onload',' var headID = document.getElementsByTagName("head")[0]; if(headID) { var newScript = document.createElement(\'script\'); newScript.type = \'text/javascript\'; newScript.src = \''.BASE_URL.'/cron.php?type=javascript\'; headID.appendChild(newScript); } '); if($PMDR->get('javascript_onload')) { $onLoad = '<script language="javascript" type="text/javascript" charset="'.CHARSET.'">'; $onLoad .= "function onLoad() {\n"; $onLoad .= implode("\n",$PMDR->get('javascript_onload')); $onLoad .= "\n}"; $onLoad .= 'window.onload=onLoad;'."\n"; $onLoad .= '</script>'."\n"; $PMDR->loadJavascript($onLoad); unset($onLoad); } $javascript .= implode("\n",(array) $PMDR->get('load_javascript')); $header->set('load_javascript',$javascript); $header->set('load_css',implode("\n",(array) $PMDR->get('load_css'))); $header->set('css_file_path',BASE_URL.TEMPLATE_PATH.'css.css'); // Add title from configuration to end of array and display, seperated by a dash - //$PMDR->set('page_title',array_merge(array_reverse($PMDR->get('page_title')),array($PMDR->getConfig('title')))); $header->set('page_title',implode(' - ',array_merge(array_reverse($PMDR->get('page_title')),array($PMDR->getConfig('title'))))); if($PMDR->get('breadcrumb')) { $header->set('breadcrumb',$PMDR->get('breadcrumb')); } ?> Thanks |