JavaScript - Urgent!!!:how To Click On A Data In Paging?
hi
i am doing a project and now i am try to work on paging, however i am stuck. I want to put in a list of links of website in the itemfilereadstore. So when show, i want to be able to click on any one of the link in the page, which will bring you to the selected website reference guide: http://dojotoolkit.org/reference-gui...agination.html Similar Tutorialshi i recently working on a project i need to create hard code first of list of element something like the below of code but i not sure if i declare this array correctly? var it = [{ "id": "1001", "type": "Regular" },{ "id": "1002", "type": "Chocolate" },{ "id": "1002", "type": "Blueberry" },{ "id": "1004", "type": "Devil's Food" }] secondly, i want to show all the data that have same id..so how should do ? must i for loop and if loop...cause i know need to if loop....is it meaning using continue statement i need to show in when i click on a link and those with the same id will display in the dialog can show any example PS...reply asap!!! thanks!!!!!! I am doing a project and I have a problem. I have retrieved data from a json file using ajax and the xmlhttprequest, but I am not able to put the content I retrieve into the dojo content pane. The content pane is inside a border container. I have tried the following, but it does not work. The HTMLPage4.html has the json data inside. please help me really urgent to me!!!!!!!as soon as possible Code: function getInfoContent(graphic) { function ajaxRequests() { var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE if (window.ActiveXObject) { //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken) for (var i = 0; i < activexmodes.length; i++) { try { return new ActiveXObject(activexmodes[i]) } catch (e) { //suppress error } } } else if (window.XMLHttpRequest) // if Mozilla, Safari etc return new XMLHttpRequest() else return false } var mygetrequests = new ajaxRequests() mygetrequests.onreadystatechange = function() { if (mygetrequests.readyState == 4) { if (mygetrequests.status == 200 || window.location.href.indexOf("http") == -1) { var bookss = eval("(" + mygetrequests.responseText + ")") //retrieve result as an JavaScript object var rssent = bookss.infos.info for (var i = 0; i < rssent.length; i++) { // alert(mygetrequests.responseText); var placeImg = "" var txt = "" // placeImg += rssent[i].descImg txt += rssent[i].desc var shorttxt = "" shorttxt += txt.substring(0, 30); var bc = new dijit.layout.BorderContainer({ style: "font-size: 11pt; height: 574px; width:739px; border:0px;" }); var c1 = new dijit.layout.ContentPane({ region: "top", style: "height: 11.5%; width: 100%; color: black; background-color: transparent; border:0px;", content: "<table><div id = \"mydiv\">" + shorttxt + "<font color = '#0000FF' size = '1'><a onclick='showmore();'><u> More...</u></a></div></td></table>" }); bc.addChild(c1); } } else { alert("An error has occured making the request") } } return bc.domNode; } mygetrequests.open("GET", "HTMLPage4.htm", true) mygetrequests.send(null) } hellow, i try to make a script that gets data from my mysql-database and displays it in a form with check boxes. if i select one or more check boxes the data with its checkbox should move to another column in the table in this form. all the other data and there checkboxes not selected should stay at its own place. in the future i want to work with 150 checkboxes. the part for getting it out off the database and display it in the form with the checkboxes is completed in PHP. but i'm stuck changing its place with the onclick handler from javascript. here you can see it working (but it's written when you click auto1 an click submit all the checkboxes change place and are selected) http://silent.comxa.com/m.php the code i have so far is: PHP Code: <? $ch11 = ''; $ch11 = $_POST['auto1']; $checked = isset($_POST['submit1']) && $_POST['auto1'] == 'on' ? 'checked="checked"' : ''; ?> </head> <body> <? @$cat=$_GET['cat']; if(strlen($cat) > 0 and !is_numeric($cat)){ echo "Data Error"; exit; } ///////// Getting the data from Mysql table ////////// $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category"); ?> <form method="post" name="f2" action="m.php"><table width="828" border="1"> <?php while($noticia2 = mysql_fetch_array($quer2)) { if ($ch11 =='on'){ echo '<tr><td width="200" > </td><td width="300" > </td> <td width="200" > <input name="'.$noticia2[category].'" type="checkbox"'.$checked.'/> '.$noticia2[category].' </td><td width="100">'.$noticia2[cat_id].'</td></tr>'; } else { echo '<tr><td width="200" > <input name="'.$noticia2[category].'" type="checkbox"'.$checked.'/> '.$noticia2[category].' </td><td width="300" >'.$noticia2[cat_id].'</td><td width="200" > </td><td width="100" > </td></tr>';} } ?> </table> <?php echo '<input type="submit" name = "submit1" value="Submit"/>'; echo '</form>'; ?> Hi. Please help. I have a credit card donation page and what I wanted to do is after they click the submit button and transaction is successfult I wanted to capture the donation amount they enter from the donation page and show it to the next page. I know that is possible but I just don't know how to do it. I am new in Javascript and still consider as a baby. Can someone please help? Thanks in advance.
I am developing simple quiz page using php and JavaScript. i have 24 questions in 6 pages which i was loaded from a xml file. i just want to do the validation page by page. those pages loading from JavaScript paging functions. Now the validations happen to all 24 questions. i need to do the validations only in the current page then the other page.. here is a sample link which i want to develop...(the quiz thing) http://www.careerpath.com/career-tests/career-quiz/ please help me... Code: <table border=0 width=520px> <tr> <td > <div style=" border:0px solid gray;"> <br> <div style="width:400px;height:52px;background:url(images/head-careerpath-quiz-test.gif ) no-repeat;valign:middle;margin-left:25px;line-height:52;"></div> <div style="width:500px;padding-left:10px;"> <fieldset> <form id="formID" class="formular" action="result.php" method="get"> <b>Getting Started</b> <br> <br> There are 24 pairs of statements below. As you read each pair, click the one statement in each pair that has the most appeal for you. As you select, assume that each choice is equal in pay, prestige, and challenge. If you are uncertain of a job title, select the one that has the most appeal for you. <br><br><div style="width:470px;height:31px;valign:middle;line-height:31px; color:#FFF;background:url(images/question_header_single_test.gif) no-repeat;"> <b>Please respond to the following statements.</b> </div> <div style="width:470px; background:#ece6f8;"> <table id="results" border=0> <tr> <th></th> <th></th> </tr> <?php // set name of XML file $file = "question.xml"; // load file $xml = simplexml_load_file($file) or die ("Unable to load XML file!"); ?> <?php foreach ($xml->question as $section) {$quesionindex++; ?> <tr> <td valign="top"> <?php echo $section->qno.".";?></td> <td valign="top"> <input class="validate[required] radio" type='radio' id="answer1_<?php echo $section->qno;?>" name="<?php echo $section->qno;?>" value='0' ><?php echo $section->answer1->answer;?> <br /> <input class="validate[required] radio" type='radio' id="answer2_<?php echo $section->qno;?>" name="<?php echo $section->qno;?>" value='1'><?php echo $section->answer2->answer;?> </td> </tr> <?php } ?> </table> <br><br> <div id="pageNavPosition"></div> <br> <div><input class="submit" type="submit" /><input type="reset" /></div> </div> </form> <script type="text/javascript"><!-- var pager = new Pager('results', 6); pager.init(); pager.showPageNav('pager', 'pageNavPosition'); pager.showPage(1); //--></script> </fieldset> </div> </div> </div> </td> </tr> </table> here is the javascript i am using for paging Code: function Pager(tableName, itemsPerPage) { this.tableName = tableName; this.itemsPerPage = itemsPerPage; this.currentPage = 1; this.pages = 0; this.inited = false; this.showRecords = function(from, to) { var rows = document.getElementById(tableName).rows; // i starts from 1 to skip table header row for (var i = 1; i < rows.length; i++) { if (i < from || i > to) rows[i].style.display = 'none'; else rows[i].style.display = ''; } } this.showPage = function(pageNumber) { if (! this.inited) { alert("not inited"); return; } var oldPageAnchor = document.getElementById('pg'+this.currentPage); oldPageAnchor.className = 'pg-normal'; this.currentPage = pageNumber; var newPageAnchor = document.getElementById('pg'+this.currentPage); newPageAnchor.className = 'pg-selected'; var from = (pageNumber - 1) * itemsPerPage + 1; var to = from + itemsPerPage - 1; this.showRecords(from, to); } this.prev = function() { if (this.currentPage > 1) this.showPage(this.currentPage - 1); } this.next = function() { if (this.currentPage < this.pages) { this.showPage(this.currentPage + 1); } } this.init = function() { var rows = document.getElementById(tableName).rows; var records = (rows.length - 1); this.pages = Math.ceil(records / itemsPerPage); this.inited = true; } this.showPageNav = function(pagerName, positionId) { if (! this.inited) { alert("not inited"); return; } var element = document.getElementById(positionId); var i=1; var pagerHtml = '<span onclick="' + pagerName + '.prev();i--;" class="pg-normal"> « Prev </span> | '; for (var page = 1; page <= this.pages; page++) pagerHtml += '<span id="pg' + page + '" class="pg-normal" onclick="' + pagerName + '.showPage(' + page + ');">' + '' + '</span> '; //pagerHtml += '<span id="pg' + page + '" class="pg-normal" onclick="' + pagerName + '.showPage(' + page + ');">' + '' + '</span> '; pagerHtml += '<input value="Continue" type="submit" onclick="'+pagerName+'.next();" class="pg-normal"/> '; element.innerHTML = pagerHtml; } } hi, At the moment when I select a county from the dropdown list, they show in the <div id="ajaxDiv"> - HttpRequest is loading apage, I'd like to do this with the pagination?! JavaScript Code: function ajaxFunction(){ var townRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari townRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ townRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ townRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server townRequest.onreadystatechange = function(){ if(townRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = townRequest.responseText; } } var name = document.getElementById('name').value; var rsCounty = document.getElementById('rsCounty').value; var rsTown = document.getElementById('rsTown').value; var queryString = "?name=" + name + "&rsCounty=" + rsCounty + "&rsTown=" + rsTown; //Add the following line townRequest.open("GET", "http://www.mypubspace.com/townpubs.php" + queryString, true); townRequest.send(null); } function countyFunction(){ var countyRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari countyRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ countyRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ countyRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server countyRequest.onreadystatechange = function(){ if(countyRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = countyRequest.responseText; } } var name = document.getElementById('name').value; var rsCounty = document.getElementById('rsCounty').value; var rsTown = document.getElementById('rsTown').value; var queryString = "?name=" + name + "&rsCounty=" + rsCounty + "&rsTown=" + rsTown; //Add the following line countyRequest.open("GET", "http://www.mypubspace.com/countypubs.php" + queryString, true); countyRequest.send(null); } form shows list of counties: Code: <form name="form3" method="post" action=""> <!--<select name="menu2" onChange="MM_jumpMenu('parent',this,0)" class="textbox">--> <select name="menu2" onChange="countyFunction();" class="textbox" id="rsCounty"> <option value="">Search by County...</option> <? $county_pubs = mysql_query("SELECT DISTINCT RSCOUNTY, COUNT(PUBID) As PubCount1 FROM pubs GROUP BY RSCOUNTY ORDER BY RSCOUNTY ASC") ?> <?php while($row1 = mysql_fetch_array($county_pubs)) { echo '<option value="'.$row1['RSCOUNTY'].'">'.$row1['RSCOUNTY'].' ('.$row1['PubCount1'].')</option>'; } ?> </select> <input type='hidden' id='name' /> <input type='hidden' id='rsCounty' /> <input type='hidden' id='rsTown' /> </form> where I place: <div id="ajaxDiv"></div> this shows the countypubs.php page countypubs.php page Code: <?php $dbhost = "xxx"; $dbuser = "xxx"; $dbpass = "xxx"; $dbname = "xxx"; //Connect to MySQL Server mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); if ($msg <>"") { echo "<div class=\"ui-widget\"> <div style=\"padding: 0pt 0.7em;\" class=\"ui-state-error ui-corner-all\"> <p style=\"padding-top:18px;\"><span style=\"float: left; margin-right: 0.3em;\" class=\"ui-icon ui-icon-alert\"></span> <strong>Alert:</strong> $msg</p> </div> </div>"; } $county = $_GET["rsCounty"]; echo $county .'<br />'; $tableName="pubs"; $targetpage = "default.php"; $limit = 20; $query = "SELECT COUNT(*) as num FROM $tableName WHERE rsCounty = '$county'"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = mysql_escape_string($_REQUEST['page']); if( isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) ) { $page = (int) $_GET['page']; $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName WHERE rsCounty = '$county' ORDER BY rsPubName Asc LIMIT $start, $limit"; $result = mysql_query($query1); // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<span class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='$targetpage?page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</span>"; } echo 'Pubs found: '.$total_pages; // pagination echo $paginate; ?> <div id="ajaxCountylist"> <div id="accordion"> <?php while($row = mysql_fetch_array($result)) { echo '<div><h3><a href="#">'.$row['rsPubName'].', '.$row['rsTown'].'</a></h3><div>'.$row['rsAddress'].'<br />'.$row['rsTown'].', '.$row['rsCounty'].'<br />'.$row['rsPostCode'].'<br /><br />Region: '.$row['Region'].'<br /><br />Telephone: '.$row['rsTel'].'<br /><br />'; echo '<button onclick="gohere(\'viewpub.php?PUBID='.$row['PUBID'].'\')" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">View Pub</span></button>'; echo '</div></div>'; } echo '<span style="float:right;">'.$paginate.'</span>'; ?> </div> </div> how do I do the same as what I am doing here to my pagination? here is the URL: http://www.mypubspace.com Hi all, I'm having trouble paging from six to six the search results coming from a webservice, hope someone can help : Let's see it with an example: The variable that stores the number of elements of the search results array is called contentLenght. Let's say that contentLenght equals 9. Then I need a div showing 6 elements an another sowing 3 elements. If contentLenght equals 7, I need a div showing 6 elements an another showing one element. If the value of contentLenght is 18, then I need three divs containing 6 elements each.. and so on. Now the paging itself: if I have just one div there's no need for paging, but if I have two of more I have to show the page's numbers. Then when a number is clicked the present div must hide and the div containing the elements for the page number should show. Am I right with the approach? I was about to paste some code but the only way I've come out with the six to six paging is with a long if else structure, and I'm sure there's a smarter way of doing it. Thanks a ton in advance Ok know those people who are in the bad habit of double clicking everything? Well my site breaks if they double click it... is there a script I can use that won't let my functions run more then once every so many seconds? to avoid double clicking errors? Hey guys just need a little help. I need to create a little script that clicks a link automatically and opens it up in a new page. So far I have this: Code: <head> <script> function autoClick(){ document.getElementById('linkToClick').click(); } </head> <body onload="setTimeout('autoClick();',3000);"> <a id="linkToClick" href="http://www.google.com" rel="nofollow" target="_blank">GOOGLE</a> </body> It works but the problem is that IE popup blocker keeps blocking the new window. Is there a way to do the same thing with javascript without it having blocked by IE popup blocker? need to make "left click" act as "middle click" -------------------------------------------------------------------------------- I need to make "left click" act as "middle click" for a web site ....thank you in advance for any and all help... [CODE] <script language="javascript"> function Click(4) { if (event.button==0; 1; ) } document.onmousedown </script>> I'm a newbie to php and javascript. I want some checkbox to hide some rows of my table so i did a search and i found a few javascript codes but yet I couldn't make it work the way I wanted it. When I uncheck a checkbox ONLY the first table rows get hidden, the other tables don't? can't I ID some rows? Please I need help :( My javascript code is: Quote: <script type="text/javascript"><!-- function showHideTR(idx,vis) { var tbl,row; if(document.getElementById && document.getElementsByTagName) { tbl = document.getElementById('tbl'); if(!tbl || (idx >= tbl.getElementsByTagName('tr').length)) return; row = tbl.getElementsByTagName('tr')[idx]; } else if(document.all && document.all.tags) { // IE4 support tbl = document.all.tbl; if(!tbl || (idx >= tbl.all.tags('tr').length)) return; row = tbl.all.tags('tr')[idx]; } if(row) { if(!vis) { row.style.display = 'none'; } else { // conditional compilation to hide the try-catch blocks from IE4 /*@cc_on @if(!@_jscript || (@_jscript_version >= 5)) @*/ try { row.style.display = 'table-row'; } catch(e) { row.style.display = 'block'; } /*@elif(@_jscript_version < 5) row.style.display = 'block'; // for IE4 @end @*/ } } } function getStyle(el,styleProp) { var x = (typeof(el)=='string')?document.getElementById(el):el; if (x.currentStyle) var y = x.currentStyle[styleProp]; else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); return y; } window.onload = function() { if(!document.getElementsByTagName) return; var tds = document.getElementsByTagName('td'); for(var i=0;i<tds.length;i++) { tds[i].onclick = function() { alert(this.parentNode.tagName+' = display : '+getStyle(this.parentNode,'display')+ '\n'+this.tagName+' = display : '+getStyle(this,'display')); } } } // --> </script> <!-- <script type="text/javascript"> function showHideTR(idx,vis) { var tbl,val; val = (!vis)?'none':((document.defaultCharset && !window.home)?'block': 'table-row'); if(document.getElementById && document.getElementsByTagName) { tbl = document.getElementById('tbl'); if(idx >= tbl.getElementsByTagName('tr').length) return; tbl.getElementsByTagName('tr')[idx].style.display = val; } else if(document.all && document.all.tags) { // IE4 support tbl = document.all.tbl; if(idx >= tbl.all.tags('tr').length) return; tbl.all.tags('tr')[idx].style.display = val; } } </script> --> My option tags: Quote: <form action="#" onsubmit="return false;"> <ul> <li2><label for="cb0"><input type="checkbox" id="cb0" checked="checked" onclick="showHideTR(0,this.checked);"> Blah Blah</label></li> <li2><label for="cb1"><input type="checkbox" id="cb1" checked="checked" onclick="showHideTR(1,this.checked);"> Blah Blah2</label></li> <li2><label for="cb2"><input type="checkbox" id="cb2" checked="checked" onclick="showHideTR(2,this.checked);"> Blah Blah3</label></li> <li2><label for="cb3"><input type="checkbox" id="cb1" checked="checked" onclick="showHideTR(3,this.checked);"> Blah Blah4</label></li> </ul> </form> My php page: Quote: <?php $host = "localhost"; // your host name $username = "blah blah"; // your user name to access MySql $password = "blah blah"; // your password to access MySql $database = "blah blah"; // The name of the database $no = $_POST["sureno"]; //$link = mysql_connect($host,$username,$password); if (!$link = @mysql_connect($host,$username,$password,true)) {die('Could not connect:'. mysql_error()); } @mysql_query("SET NAMES 'latin5'"); @mysql_select_db($database) or die( "Unable to select database"); $sql="SELECT * FROM blah blah WHERE sure = '$no' ORDER BY 'id'"; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } while($row=mysql_fetch_assoc($result)){ $bgcolor="#f1f1f1"; echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0 id='tbl' summary='demonstration'> <tr>"; echo "<td bgcolor='dfdfdf' ><font face='arial,verdana,helvetica' color='#000000' size='3'>blah blah</font></td>"; echo "<td bgcolor='C0C0C0' ><font face='arial,verdana,helvetica' color='#FF0000' size='4'>" . $row['AB'] ."</font></td></tr>"; echo "<tr><td bgcolor='dfdfdf' ><font face='arial,verdana,helvetica' color='#000000' size='3'>blah blah</font></td>"; echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#0080C0' size='2'>". $row['TR'] ."</font></td></tr>"; echo "<tr><td bgcolor='dfdfdf' ><font face='arial,verdana,helvetica' color='#000000' size='3'>blah blah</font></td>"; echo "<td bgcolor='dfdfdf' id='cb0'> <font face='arial,verdana,helvetica' color='#000000' size='3'>". $row['ML'] ."</font></td></tr>"; } mysql_free_result($result); ?> im new beginner for jsp coding and java script programming..here,i have a few question about date calculation. 1.duration date between date signed and expired date = display in year 2. from expired date available years, month and day minus with Date Today 3. how to use IF ELSE statement to display status active or inactive (example : active status if more then 8 month or inactive status if less then 8 month) this is my coding...it's right? for years <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ function DaysMonths(but,nme,op){ var frm=but.form; var dates=frm[nme]; for (var i=0; i<dates.length; i++){ var date=dates[i].value.split('-'); dates[i].date=new Date(date[0]*1,date[1]-1,date[2],0,0,0,0); } var days=(dates[1].date-dates[0].date)/1000/60/60/12; years=(dates[1].date.getFullYear()-dates[0].date.getFullYear()); frm[op].value=years+' years'; } /*]]>*/ </script> i have output : 5 years for month and day <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ function DaysMonth(but,nme,op){ var d = new Date(); var frm=but.form; var dates=frm[nme]; for (var i=0; i<dates.length; i++){ var date=dates[i].value.split('-'); dates[i].date=new Date(date[0]*1,date[1]-1,date[2],0,0,0,0); } var days=(dates[1].date-dates[0].date)/1000/60/60/24s; var months=dates[1].date.getMonth()-dates[0].date.getMonth(); months=(dates[1].date.getFullYear()-dates[0].date.getFullYear()-d.getDate())*12+(months<0?months:-months); frm[op].value= months + ' month ' +days+ ' day '; } /*]]>*/ </script> my output i have like this : 48 month 1826 day i set date format in my sql like this date signed = 2008-11-18 date expired = 2013-11-18 how can i have output like this for for duration (date expired - date signed) minus date for today = 3 year, 42 month 1826 day sorry for my thread post this morning...not mean like that... Hi I'm trying to create a javascript function that will ask a user for a character and check that character against a string containing other characters. If the character is present in the string the function should then ask the user to input another character. it should keep doing this until a charater is entered that doesnt appear in the check string. I am pretty new to javascript and have been working for about 2 days trying to get this to work. I have an assignment due next week 21.09.09 and need to get it sorted before then. Any help or pointers would be great. One stipulation that the assignment is asking for is that you have to use the indexOf method to interigate the string. I have attached the code below. Any help or pointers would be brilliant. var incorrectString = 'abcdef'; var correctString = 'ghi'; function getInput(aString) { } getInput(incorrectString + correctString); Hai everyone, I am a newbie to javascript.I have a scenario where I have two sets of textboxes,one that holds the percentage and other holds the percenteage value. Below them,I have a total value of which the percentage values will be stored. Can anyone help me in writing the javascript code in finding the percentage value of the total number given below and storing it in a text box. Any help,I need it urgent can any one please help me out with the code. I am passing an URL for ex: www.example.com?req=23¶m=25 What i need to do is I need to remove the parameters after "?" which I did using the spilt method, Can anyone help me out now how do I send the complete URL with the parameters as hidden. what I mean is..my URL should look like www.example.com. but the second part (parameter shud be hidden). Hi, i am new to javascript and i am giving a task to create a javascript page, i need a javascript that will calculate and generate a simple Quotation with total price of item selected and its quantity in a new page and in tabular form, i need this for 2 check-boxs that has the value, 2 dropdownlist and the price.
I am a beginner so please help ASAP. When I validate my code in validate.w3.org: document.write("<img src='" + myNum +".jpg'/>"); I got an error that said: --- required attribute "alt" not specified here's what I have so far Code: <html> <head> <script> MONTHS_OF_THE_YEAR = 'janfebmaraprmayjunjulaugsepoctnovdec'; MILLISECONDS_DAY = 1000*60*60*24; MILLISECONDS_YEAR = 1000*60*60*24*365.2424; LIFE_EXPECTANCY = 1000*60*60*24*365.2424*67.2; var daysArray = new Array ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); var yearBirth = ''; yearBirth = prompt('Please enter your year of birth'); var monthBirth = ''; monthBirth = prompt('Please enter your month of birth'); monthBirth = monthBirth.slice(0,3); monthBirth = monthBirth.toLowerCase(); monthBirth = MONTHS_OF_THE_YEAR.indexOf(''+monthBirth)/3; var dateBirth = ''; dateBirth = prompt('Please enter your date of birth'); var usersInputDate = new Date (yearBirth, monthBirth, dateBirth); var dd = new Date((monthBirth+1).toString() + "/" + dateBirth + "/" + yearBirth); dd=dd.getDay(); var now = new Date(); usersInputTime = (usersInputDate.getTime()); usersInputTime = parseInt(now.getTime()-usersInputTime); var ageYears = (usersInputTime/MILLISECONDS_YEAR); var ageDays = (usersInputTime/MILLISECONDS_DAY); var avgLife = (usersInputTime/LIFE_EXPECTANCY*100); document.writeln('<h1>It\'s about time...</h1>'); document.writeln('<ul>'); document.writeln('<li> </li>' </script> </head> <body> </body> </html> I need to do the following and have no idea Quote: What will be output (to the document using write())? A heading 1 title with the text It's about time... An unordered list containing appropriate wording as strings concatenated with: The weekday name for the user's birth date Use the day of the week number as an index into the weekday names array The user's age in years Present this as a fixed format number with 2 decimal places The user's age in days Present this as a fixed format number with 0 decimal places The percentage of an average life expectancy Present this as a fixed format number with 0 decimal places please help i need to get this done tonight Hi Guys, I am implementing this Javascript in my summer internship. What I want to do is, 1) Show a Pop up alert with a Countdown timer( 10, 9, 8, 7 ....) after 5 minutes. 2) If user doesn't click "Ok" within the time, the page will automatically Redirect to another page. Eg- Login Page. 3) If the User clicks the "Ok" button the Page will not get re-direct. 4) Also, once the Timer countdown completes and the page redirection is done, the User when he will see the Login page will see an alert box saying. 'Your session has expired, plz login again' he clicks 'Ok' and Login again. I am very new to this Java script, but need to finish this project. Plz help me out. |