Search the Community
Showing results for tags 'javascript'.
-
I am trying to have a js alert box to confirm before deleting a record. Here is the js code. <script> function confirmation() { var answer = confirm("Are you sure?") if (answer){ alert("This record been deleted!") } else{ alert("Not deleted!") } } </script> php code. <a href="delete.php" onclick="confirmation()">Delete record</a> The problem is, even if i click no in the js alert box and the message shows("Not deleted!"), it still deletes the record. Why is it doing that? My second question is, is it possible to css the js alert box? I need to customize it to my own look.
- 2 replies
-
- php
- javascript
-
(and 3 more)
Tagged with:
-
This is a script that validates a user's email and password. Everything is super clear but I can't figure out the purpose of document.getElementById('theForm').submit(); As far as I know, it's a method that submits the form to the script referenced inside the forms html action tag eg. <form action="login.php"> (just in case ajax fails for whatever reason). But I can't find any information to validate this. function validateForm() { 'use strict'; // Get references to the form elements: var email = document.getElementById('email'); var password = document.getElementById('password'); // Validate! if ( (email.value.length > 0) && (password.value.length > 0) ) { // Perform an Ajax request: var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange = function() { if (ajax.readyState == 4) { // Check the status code: if ( (ajax.status >= 200 && ajax.status < 300) || (ajax.status == 304) ) { if (ajax.responseText == 'VALID') { alert('You are now logged in!'); } else { alert('The submitted values do not match those on file!'); } } else { document.getElementById('theForm').submit(); } } }; ajax.open('POST', 'resources/login.php', true); ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); var data = 'email=' + encodeURIComponent(email.value) + '&password=' + encodeURIComponent(password.value); ajax.send(data); return false; } else { alert('Please complete the form!'); return false; } } // End of validateForm() function. // Function called when the window has been loaded. // Function needs to add an event listener to the form. function init() { 'use strict'; // Confirm that document.getElementById() can be used: if (document && document.getElementById) { var loginForm = document.getElementById('loginForm'); loginForm.onsubmit = validateForm; } } // End of init() function. // Assign an event listener to the window's load event: window.onload = init;
-
I'm having a bit of trouble with a PHP contact form. There are issues with the error messages not showing on the form, the form not resetting, and the "name" input appearing as "X-AuthUser: XXX123 (which happens to be my FTP user name which I'm keeping private) when the email is sent to my gmail account. This is how the theme should look: http://pluto.html.themewoodmen.com/07-pluto-contact.html And this is what I have: http://divagraphics.us/test/contact.html The HTML <div class="contactForm"> <div class="successMessage alert alert-success alert-dismissable" style="display: none"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> Thank You! E-mail was sent. </div> <div class="errorMessage alert alert-danger alert-dismissable" style="display: none"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> Ups! An error occured. Please try again later. </div> <form class="liveForm" role="form" action="form/send.php" method="post" data-email-subject="Contact Form" data-show-errors="true" data-hide-form="false"> <fieldset> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label class="control-label">Name <span>(Required)</span></label> <input type="text" required name="name" class="form-control" id="name"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="control-label">Email <span>(Required)</span></label> <input type="email" required name="email" class="form-control" id="email"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label">Subject</label> <input type="text" name="subject" class="form-control" id="subject"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label">Message <span>(Required)</span></label> <textarea name="message" required class="form-control" rows="5" id="message"></textarea> </div> </div> </div> <input type="submit" class="btn btn-primary" value="Send Message"> </fieldset> </form> </div> The JS /** * Contact Form */ jQuery(document).ready(function ($) { "use strict"; $ = jQuery.noConflict(); var debug = false; //show system errors $('.liveForm').submit(function () { var $f = $(this); var showErrors = $f.attr('data-show-errors') == 'true'; var hideForm = $f.attr('data-hide-form') == 'true'; var emailSubject = $f.attr('data-email-subject'); var $submit = $f.find('[type="submit"]'); //prevent double click if ($submit.hasClass('disabled')) { return false; } $('[name="field[]"]', $f).each(function (key, e) { var $e = $(e); var p = $e.parent().find("label").text(); if (p) { var t = $e.attr('required') ? '[required]' : '[optional]'; var type = $e.attr('type') ? $e.attr('type') : 'unknown'; t = t + '[' + type + ']'; var n = $e.attr('name').replace('[]', '[' + p + ']'); n = n + t; $e.attr('data-previous-name', $e.attr('name')); $e.attr('name', n); } }); $submit.addClass('disabled'); $f.append('<input class="temp" type="hidden" name="email_subject" value="' + emailSubject + '">'); $.ajax({ url: $f.attr('action'), method: 'post', data: $f.serialize(), dataType: 'json', success: function (data) { $('span.error', $f).remove(); $('.error', $f).removeClass('error'); $('.form-group', $f).removeClass('has-error'); if (data.errors) { $.each(data.errors, function (i, k) { var input = $('[name^="' + i + '"]', $f).addClass('error'); if (showErrors) { input.after('<span class="error help-block">' + k + '</span>'); } if (input.parent('.form-group')) { input.parent('.form-group').addClass('has-error'); } }); } else { var item = data.success ? '.successMessage' : '.errorMessage'; if (hideForm) { $f.fadeOut(function () { $f.parent().find(item).show(); }); } else { $f.parent().find(item).fadeIn(); $f[0].reset(); } } $submit.removeClass('disabled'); cleanupForm($f); }, error: function (data) { if (debug) { alert(data.responseText); } $submit.removeClass('disabled'); cleanupForm($f); } }); return false; }); function cleanupForm($f) { $f.find('.temp').remove(); $f.find('[data-previous-name]').each(function () { var $e = jQuery(this); $e.attr('name', $e.attr('data-previous-name')); $e.removeAttr('data-previous-name'); }); } }); The PHP <?php // Contact subject $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $to = "[email protected]"; $from = $_POST['email']; $headers = "From: $from"; mail($to,$subject,$message,$headers) ?>
- 2 replies
-
- php
- contact form
-
(and 3 more)
Tagged with:
-
function updateTimers() { //Get the current timestamp now = new Date(); //Iterate through each of the timers for(i=0; i<timers.length; i++) { //Convert end time to timestamp & calc difference endTime = new Date(timers[i].split(' ').join('T')); millisecondsDiff = endTime - now; //Format the diff and display timeDisplay = formatTimeDiff(millisecondsDiff); document.getElementById('timer['+i+']').innerHTML = timeDisplay; } } I'm using the above function to set timers for a page on my website. It should be showing 23 minutes but is showing 83 minutes. This has only come about since the clocks in the UK went forward. Ant help?
-
Here is a script i wrote so i could refresh a div with content every 5 seconds but for some reason it doesnt work ... i wanted it to load it with the page then start the refresh i didnt want it to have to wait for the refresh to show up. <script type="text/javascript"> function page_load(){ $('#contentforads').load('<?php print $actual_link ?>/ads.php').fadeIn("slow"); } function refresh(){ page_load() var auto_refresh = setInterval(page_load(),5000); } </script>
- 2 replies
-
- jquery
- javascript
-
(and 1 more)
Tagged with:
-
I am running this query and the only thing i want is the title and for some reason it is giving me this. Recourse id # 7 ? Here is my query that i am running. $photo = $_GET['image']; $retrievetitle = "SELECT title FROM photo_from_user WHERE picture = '$photo' limit 1"; $title = mysql_query($retrievetitle);
-
Hi I want to submit the form automatically after sometime,. I have written the code , but its not redirecting/submitting. Don't know why.. Have a look Thanks <!DOCTYPE html> <html> <head> <script type="text/javascript"> setTimeout(function(){document.getElementById("exam").submit()},2000); </script> </head> <body> <?php date_default_timezone_set('Asia/Kolkata'); echo"Start Time: ".$starttime=date('H:i:s')."<br/><br/>"; $startstamp=time(); ?> <form action="inde x1.php" method="post" id="exam" name="exam"> Q1 Your Gender<br/> <input type="radio" value="male" name="gender"> Male <input type="radio" value="female" name="gender"> Female <br /><br /><br /> Q2 You Married<br/> <input type="radio" value="yes" name="marriage"> Yes <input type="radio" value="female" name="marriag e"> No <br /><br /><br /> Q3 2+2<br/> <input type="radio" value="4" name="add"> 4 <input type="radio" value="22" name="add"> 22 <input type="hidden" value="<?php echo $starttime; ?>" name="starttime"><br/> <input type="hidden" value="<?php echo $startstamp; ?>" name="startstamp"><br/> <input type="submit" name="submit"> </form> </body> </ html>
- 10 replies
-
Hello all, I am designing a program that consists of 1 dropdown list that pulled the value from the ORACLE DB and update the value as we change the Dropdown. I can get everything works except the submit button when we want to update the value. Please help me, I know this is a very simple problem but somehow it doesnt work. Your help with greatly appreciated. Thanks, // ASSUME CONNECTION IS DONE if (isset($_POST["ajax"]) && $_POST["ajax"] == 1) { $sql = "SELECT QTY FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $cutting_sql = "SELECT CUTTING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $assembly_sql = "SELECT ASSEMBLY FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $welding_sql = "SELECT WELDING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $drilling_sql = "SELECT DRILLING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $finishing_sql = "SELECT FINISHING FROM FABRICATION WHERE HEAD_MARK = '{$_POST["hm"]}'"; $stid = oci_parse($conn, $sql); $stid_cutting = oci_parse($conn, $cutting_sql); $stid_assembly = oci_parse($conn, $assembly_sql); $stid_welding = oci_parse($conn, $welding_sql); $stid_drilling = oci_parse($conn, $drilling_sql); $stid_finishing = oci_parse($conn, $finishing_sql); // The defines MUST be done before executing oci_define_by_name($stid, 'QTY', $qty); oci_execute($stid); oci_define_by_name($stid_cutting, 'CUTTING', $cutting); oci_execute($stid_cutting); oci_define_by_name($stid_assembly, 'ASSEMBLY', $assembly); oci_execute($stid_assembly); oci_define_by_name($stid_welding, 'WELDING', $welding); oci_execute($stid_welding); oci_define_by_name($stid_drilling, 'DRILLING', $drilling); oci_execute($stid_drilling); oci_define_by_name($stid_finishing, 'FINISHING', $finishing); oci_execute($stid_finishing); // Each fetch populates the previously defined variables with the next row's data oci_fetch($stid); oci_fetch($stid_cutting); oci_fetch($stid_assembly); oci_fetch($stid_welding); oci_fetch($stid_drilling); oci_fetch($stid_finishing); //echo quantity to the screen echo "<b><font size='10'>".$qty."</font></b></br>"; if ($cutting == $qty){ echo "<p><b><font color='#FF8566' size='5'>CUTTING COMPLETED</font></b></p>"; } else { $maxcutting = $qty - $cutting; echo "<input id='cutting' name='cutting' type='number' min = '0' max = '$maxcutting' placeholder='CUTTING PROGRESS TODAY' class='input'/>"; } if ($assembly == $qty){ echo "<p><b><font color='#FF8566' size='5'>ASSEMBLY COMPLETED</font></b></p>"; } else { $maxassembly = $qty - $assembly; echo "<input id='assembly' name='assembly' type='number' min = '0' max = '$maxassembly' placeholder='ASSEMBLY PROGRESS TODAY' class='input'/>"; } if ($welding == $qty){ echo "<p><b><font color='#FF8566' size='5'>WELDING COMPLETED</font></b></p>"; } else { $maxwelding = $qty - $welding; echo "<input id='welding' name='welding' type='number' min = '0' max = '$maxwelding' placeholder='WELDING PROGRESS TODAY' class='input'/>"; } if ($drilling == $qty){ echo "<p><b><font color='#FF8566' size='5'>DRILLING COMPLETED</font></b></p>"; } else { $maxdrilling = $qty - $drilling; echo "<input id='drilling' name='drilling' type='number' min = '0' max = '$maxdrilling' placeholder='DRILLING PROGRESS TODAY' class='input'/>"; } if ($finishing == $qty){ echo "<p><b><font color='#FF8566' size='5'>FINISHING COMPLETED</font></b></p>"; } else { $maxfinishing = $qty - $finishing; echo "<input id='finishing' name='finishing' type='number' min = '0' max = '$maxfinishing' placeholder='FINISHING PROGRESS TODAY' class='input'/>"; } echo '<section></br></br></br>'; echo ' <input type="submit" value="SUBMIT PROGRESS" class="button red" />'; echo ' <input type="reset" value="RESET FIELDS" class="button" /></br>'; echo ' <input type="button" value="GO TO PAINTING" name="paint" class="button green" /></section>'; if (isset($_POST['paint'])){ echo 'GO TO THE NEXT PAGE'; } if (isset($_POST['submit'])){ echo 'DO SUBMISSION TO THE DATABASE HERE'; } die;} ?> <!-- HTML CODE --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <title> Update Fabrication Progress</title> <link type="text/css" rel="stylesheet" href="../css/goldenform/golden-forms.css"/> <link type="text/css" rel="stylesheet" href="../css/goldenform/font-awesome.min.css"/> <script type="text/javascript"> function OnSelectionChange (select) { var selectedOption = select.options[select.selectedIndex]; //some ajax checkpoint //alert ("The selected option is " + selectedOption.value); jQuery.ajax({ url: location.href, data: {'hm':selectedOption.value, 'ajax':1}, type: "POST", success: function( data ) { jQuery("#lbl_qty").html(data);//PRINT QTY TO THE SCREEN } }); //some ajax checkpoint //alert('after ajax'); } </script> <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> </head> <body class="bg-wooden"> <div class="gforms"> <div class="golden-forms wrapper"> <form> <div class="form-title"> <h2>FABRICATION UPDATE</h2> </div><!-- end .form-title section --> <div class="form-enclose"> <div class="form-section"> <fieldset> <legend>  Select HEADMARK and the details will be shown <span class="bubble blue">1</span></legend> <section> <div class="row"> <div class="col4 first"> <label for="headmark" class="lbl-text tleft">HEADMARK :</label> </div><!-- end .col4 section --> <div class="col8 last"> <!-- POPULATED DROPDOWN LIST FROM THE DB --> <label for="headmark" class="lbl-ui select"> <?php $sql_hm_comp = 'SELECT HEAD_MARK FROM FABRICATION'; $result = oci_parse($conn, $sql_hm_comp); oci_execute($result); echo '<SELECT name="headmark" id="headmark" onchange="OnSelectionChange(this)">'.'<br>'; echo '<OPTION VALUE=" ">'."".'</OPTION>'; while($row = oci_fetch_array($result,OCI_ASSOC)){ $HM = $row ['HEAD_MARK']; echo "<OPTION VALUE='$HM'>$HM</OPTION>"; } echo '</SELECT>'; ?> </label> </div> </div> </section><!-- END OF DROPDOWN LIST --> <section> <div class="row"> <div class="col4 first"> <label for="lnames" class="lbl-text tleft">Total Quantity:</label> </div> <div class="col8 last"> <!-- VALUE PASSED FROM AJAX PROCESSING --> <label id='lbl_qty' class='lbl-ui'><font size='3'></font></label> </div> </div> </section> </div> </div> <div class="form-buttons"> </div> </form> </div> </div> <div></div> <div></div> </body> </html>
-
javascript is not looping with mysql_fetch_array result even though it showing timer on one product only .i don't know what mistake i have did ,,plz help me ,,i ma very new with php and java script..even i have taken javascript timer from google itself ..plz help me <?php $conn = mysql_connect('localhost','root',''); if(!$conn) die("Failed to connect to database!"); $status = mysql_select_db('bidding', $conn); if(!$status) die("Failed to select database!"); $result = mysql_query("SELECT * FROM bids where id"); $numrow = mysql_num_rows($result); if ($numrow == 0) { die('No record found.'); } ?> <?php while($row=mysql_fetch_array($result)){ $closedate = date_format(date_create($row['closing_date']), 'm/d/Y H:i:s'); $images_field= $row['image']; $image_show= "images/$images_field"; ?> <div class="bidbar1"> <div id="lastsold"><strong>Last Sold : ₹ </strong><?php echo $row['lastsold']; ?> </div> <div id="title"><?php echo $row['description']; ?></div> <div id="detail"><img src="image/moredetail.jpg" height="150" alt="more detail" /> </div> <div id="image"><img src="<?php echo $image_show; ?>" width="205" height="150" alt="more detail" /></div> <div id="clock"><table><tr><td style="font-size:18px;text-align:center; padding- left:30px;">Days Hr Min Sec</td></tr> <tr><td style="font-size:32px; font:bold; text-align:center;padding-left:30px;"> <script> var cdtd = function(id,end) { var start = new Date(); var timeDiff = end.getTime() - start.getTime(); if(timeDiff <=0 ) { //$('#bidbar1').remove(); //return; // alert('We have lift off!'); //$('#bidbar1').delay(50000000).fadeout(); $(window).load(function(){$('#bidbar1').remove(); }); return false; } var seconds = Math.floor(timeDiff / 1000); var minutes = Math.floor(seconds / 60); var hours = Math.floor(minutes / 60); var days = Math.floor(hours / 24); hours %= 24; minutes %= 60; seconds %= 60; $( id + " .days").html(days); $( id + " .hours").html(hours); $( id + " .minutes").html( minutes); $( id + " .seconds").html( seconds ); console.log(id + " .hoursBox",$( id + " .hoursBox").length,id,end,hours,minutes,seconds) var timer = setTimeout(function(){cdtd(id,end)},1000); } cdtd("#counter1",new Date("<?php echo $closedate; ?>")); //cdtd("#counter2",new Date("march 16, 2014 18:06:30")); //cdtd("#counter3",new Date("march 16, 2014 17:37:00")); //cdtd("#counter4",new Date("march 16, 2014 17:38:00")); //cdtd("#counter5",new Date("june 2, 2014 10:55:00")); //cdtd("#counter6",new Date("April 2, 2014 10:30:00")); //cdtd("#counter7",new Date("April 3, 2014 00:01:00")); //cdtd("#counter8",new Date("April 1, 2014 00:01:00")); //cdtd("#counter9",new Date("April 4, 2014 00:01:00")); //cdtd("#counter10",new Date("April 5, 2014 00:01:00")); //cdtd("#counter11",new Date("April 19, 2014 00:01:00")); //cdtd("#counter12",new Date("April 20, 2014 00:01:00")); </script> <div id="counter1"> <div class="box days">0</div> <div class="box hours">0</div> <div class="box minutes">0</div> <div class="box seconds">0</div> </div> </td></tr></table></div> <div id="mrp"><strong>MRP : ₹</strong><?php echo $row['mrp']; ?></div> <div id="endt"><strong>End Time: ₹</strong><?php echo $row['closing_date']; ?></div> <div id="fee"><strong>Bid Fee : ₹</strong><?php echo $row['bid fee']; ?></div> <div id="current"><strong>Current Winner</br>↓ </strong></div> <div id="buy"> <table width="271" border="0" cellpadding="0.1"> <tr> <td><img src="image/buy.png" alt="buy now" longdesc="http://buy now" /></td> <td width=110><?php echo $row['currentwinner']; ?></td> <td><img src="image/bid.png" alt="bid now" longdesc="http://bidnow " /></td> </tr> </table> </div></div> <?php } ?>
-
Added animated twitter bird widget code on site.. the bird appears on the site.. but when the bird moves the animation seems out of sink, not smooth.. Have a look at the site. you'll notice the problem when the bird moving... http://www.r7alh.com/ the same code working fine on my localhost. <!-- Twitter Bird Widget for Blogger by Way2blogging.org --> <script type="text/javascript" src="http://widgets.way2blogging.org/blogger-widgets/w2b-tripleflap.js"> </script> <script type="text/javascript"> var twitterAccount = "way2blogging"; var tweetThisText = " <data:blog.pageTitle/> : <data:blog.url/> "; tripleflapInit(); </script> <span style="font-size:11px;position:absolute;"><a title='Blogger Widget by Way2blogging.Org' href="http://www.way2blogging.org" target='_blank'>Blogger Widgets</a></span> <!-- Twitter Bird Widget for Blogger by Way2blogging.org --> The same code working fine on blogs and other websites. only problem is in this site.. http://www.r7alh.com/ what will be the problem? how to fix this? http://www.way2blogging.org/2011/04/add-animated-flying-twitter-bird-widget.html
-
- javascript
- wordpress
-
(and 1 more)
Tagged with:
-
I need help with my code. I'm trying to make it so that when I hit the withdraw button the money is withdrawn and the new amount is shown in the text box. As of now, when I hit the money buttons the money is withdrawn. The withdraw button does nothing. I can't figure out what I did wrong. assignment7.html
- 1 reply
-
- javascript
- html
-
(and 1 more)
Tagged with:
-
Hello everyone I have an array ( php ) which i want it to use in javascrip. i have used json encode function but this is not the problem. I want to use the values from an array and plot a graph The PHP array looks like this <?php $visits = array( 'UK' => 5, 'US' => 10, 'AS' => 15, 'AD' => 20, 'FG' => 25, 'HF' => 30, 'DG' => 35, 'JH' => 40, 'ET' => 45, 'HG' => 50, 'KT' => 55, 'ER' => 10, 'UI' => 65, 'ER' => 70, 'UY' => 75, 'UT' => 80, 'UK' => 5 ); ?> and the javascript file is <script type="text/javascript"> var arr = "<?php json_encode($visits) ?>"; $(function () { $('#container').highcharts({ chart: { type: 'area' }, title: { text: 'Total Impressions' }, subtitle: { text: '' }, xAxis: { labels: { formatter: function() { return this.value; // clean, unformatted number for year } } }, yAxis: { title: { text: 'Hits' }, labels: { formatter: function() { return this.value / 1000 +'k'; } } }, tooltip: { pointFormat: '{series.name} produced <b>{point.y:,.0f}</b><br/>warheads in {point.x}' }, plotOptions: { area: { pointStart: 1940, marker: { enabled: false, symbol: 'circle', radius: 2, states: { hover: { enabled: true } } } } }, series: [{ name: 'Country', data: [null, null, null, null, null, 6 , 11, 32, 110, 235, 369, 640, --- This are all demo values 1005, 1436, 2063, 3057, 4618, 6444, 9822, 15468, 20434, 24126, | 27387, 29459, 31056, 31982, 32040, 31233, 29224, 27342, 26662, | 26956, 27912, 28999, 28965, 27826, 25579, 25722, 24826, 24605, | <---- This is where i want to loop through the countries from my array 24304, 23464, 23708, 24099, 24357, 24237, 24401, 24344, 23586, | 22380, 21004, 17287, 14747, 13076, 12555, 12144, 11009, 10950, | 10871, 10824, 10577, 10527, 10475, 10421, 10358, 10295, 10104 ] --- }, { name: 'Hits', data: [null, null, null, null, null, null, null , null , null ,null, --- This are all demo values 5, 25, 50, 120, 150, 200, 426, 660, 869, 1060, 1605, 2471, 3322, | 4238, 5221, 6129, 7089, 8339, 9399, 10538, 11643, 13092, 14478, | 15915, 17385, 19055, 21205, 23044, 25393, 27935, 30062, 32049, | <---- This is where i want to loop through the values from my array. 33952, 35804, 37431, 39197, 45000, 43000, 41000, 39000, 37000, | 35000, 33000, 31000, 29000, 27000, 25000, 24000, 23000, 22000, | 21000, 20000, 19000, 18000, 18000, 17000, 16000] --- }] }); }); </script> Any help will be greatly appreciated... Thank in advance,....
-
I've never understood the application of return true and return false after function calls in JavaScript. Could somebody please explain their meaning. This is a very simple script which will create a popup window for each links in an html document. function createPopup(e) { 'use strict'; // Get the event object: if (typeof e == 'undefined') var e = window.event; // Get the event target: var target = e.target || e.srcElement; // Create the window: var popup = window.open(target.href, 'PopUp', 'height=100,width=100,top=100,left=100,location=no,resizable=yes,scrollbars=yes'); // Give the window focus if it's open: if ( (popup !== null) && !popup.closed) { popup.focus(); return false; // Prevent the default behavior. } else { // Allow the default behavior. return true; } } // End of createPopup() function. // Establish functionality on window load: window.onload = function() { 'use strict'; // Add the click handler to each link: for (var i = 0, count = document.links.length; i < count; i++) { document.links[i].onclick = createPopup; } // End of for loop. }; // End of onload function. The only part of the script that doesn't make sense here is the return true/false. Why do we use return true or return false after calling a JavaScript function?
- 3 replies
-
- return true
- return false
-
(and 2 more)
Tagged with:
-
Hello I'm looknig for a code that can guide me to generate four chained selects with data from mysql database, that let me add new rows to a table that maintain the same logic of the four chained select with data from mysql when I do click an add row button and so on. Anyone can give me a link or download site that I can use to build that I want? Could be a JavaScript, jquery or php code that let me do what I want in HTML. Best Regards
-
Given the following code: updateTotal: function () { var total = 0; $('input#itemLineTotal').each(function (i) { price = $(this).val().replace("$", ""); if (!isNaN(price)) total += Number(price); }); $('#subTotal').html("$" + this.roundNumber(total, 2)); var grdTotal = total + this.updateSalesTax(); grdTotal = this.roundNumber(grdTotal, 2); $('#grandTotalTop, #grandTotal').html("$" + grdTotal); }, updateSalesTax: function () { var total = 0; $('input#itemLineTotal').each(function (i) { price = $(this).val().replace("$", ""); if (!isNaN(price)) total += Number(price); }); var tax = $("#tax").val(); $("#salesTax").html("$" + mioInvoice.roundNumber(tax, 2)); return tax; }, How can add the tax to the total to give the grand total. Please help
-
Hi i want to change the attribute of a div id when the div is clicked.. but its not working for some reason ? $('#prev').attr('id',''); $('#next').attr('id','2'); //Pagination Click $(".controls").click(function(){ $("html, body").animate({ scrollTop: 0 }, 700); $('#next').removeattr('id',''); $('#prev').attr('id',''); $('#next').attr('id','7');
-
Hello mates, I'm a newbie to JavaScript. Normally when I assign an HTML element to a variable created in JavaScript I place the element id in quotes like this: var output = document.getElementById('output'); But there is something new that I've come across: var output = document.getElementById(elementId); elementId is an undeclared parameter and it is without quotes. 'output' in the first snippet refers to <p id="output"></p> in the HTML code. What is surprising to me is that var output = document.getElementById(elementId); works just the same even though there is no HTML element declared with the name elementId. To put this into context, the code is in 2 files; today.html and today.js. today.html: <html> <head> <title>Today</title> </head> <body> <p id="output"></p> <script src="today.js"></script> </body> </html> today.js: function setText(elementId, message) { 'use strict'; if ( (typeof elementId == 'string') && (typeof message == 'string') ) { // Get a reference to the paragraph: var output = document.getElementById(elementId); // Update the innerText or textContent property of the paragraph: if (output.textContent !== undefined) { output.textContent = message; } else { output.innerText = message; } } // End of main IF. } function init() { 'use strict'; var today = new Date(); var message = 'Right now it is ' + today.toLocaleDateString(); message += ' at ' + today.getHours() + ':' + today.getMinutes(); // Update the page: setText('output', message); } // End of init() function. window.onload = init;
- 1 reply
-
- getelementbyid(elementid)
- javascript
-
(and 1 more)
Tagged with:
-
Javascript CODE: var m=n=0; function show_services() { m=m+1; n=m+1; if(m==6) {m=6;n=1;} if(m==7) {m=1;n=2;} str1 = "/images/pic" + m + ".PNG"; str2 = "/images/pic" + n + ".PNG"; document.getElementById('w1').innerHTML = str1; document.getElementById('w2').innerHTML = str2; document.getElementById('img1').src = str1; document.getElementById('img2').src = str2; } var my_str = setInterval(function() {show_services()},1000); ############################################################################## <img id="img1" src="/images/pic1.PNG" style="margin-top:30px" height="100px" width="550px"/><br> <img id="img2" src="/images/pic2.PNG" style="margin-top:30px" height="100px" width="550px"/><br> <br> <div id='w1'></div> <br> <div id='w2'></div> ############################################################################## the code is working fine, files have been placed at the right place, str1 and str2 are getting correct values and they are updating at the right time..............I run same code on browser and it works fine, but, when I run the same code on website domain, it does work at all, what can be the reason for this ............
-
can someone help me?can you make this script?i dont make the script yet. when i click set as correct..., clicked response become correct answer and the other become default. thanks in advance, sorry for my bad english. iam indonesian.
- 1 reply
-
- addclass
- removeclass
-
(and 3 more)
Tagged with:
-
Hi friends, i am new in php, user fill the text box to get the value and post it to the next page using ajax. this is my requirement. i call the textbox in while loop ,so i used the text box name is ship_quantity[] In jquery i get the value like that $('input[name="ship_quantity[]"]').each(function(){ var sq=$(this).val(); alert(sq); now i get the value of 1,2 as user inputs. my questions is how to extract this values and send to ajax post.
-
Hi guys, I was wondering if i could have some help on a piece of functionality I am trying to implement onto a website I am currently developing. The Scenario is as follows : I have a table residing on a MySql data base called Bookings. The Bookings table consists of a composite primary key based upon the following 2 fields: BookingDate & Booking Slot. On my website, I have built a bookings page which will consist of a a simple HTML Form, which has a Date Field and a Radio-Button group which has 3 different time slots (eg: 9am, 2pm and 4pm). Firstly, the User will select a Date they would wish to place a booking on and then click a submit button called "Check Availablity". Once this button is clicked, Ideally, I would like a script to check an see what free slots are available for that Date and then disable the radio buttons related the slots which are already booked. Here is a simple scenario to help explain the functionality i am trying to implement : The User comes to the Bookings page, and selects the Date 14/03/2011. Then clicks the "Check Availablity" button. In this scenario, the 9am slot is already booked for this date (eg: this booking already exists on the MySql database table), so the 9am radio button on the page is then disabled, not allowing the user to try an attempt to book this timeslot on this date. Below is the a simplified version of the php script which I wrote to implement the this functionality. <?php function checkSlot() { // Get data $test_date = $_GET["bookingDate"]; // Database connection $conn = mysqli_connect("localhost","root","","wordpress"); if(!$conn) { die('Problem in database connection: ' . mysql_error()); } // Attempt to find Duplicate Primary Keys $query = "SELECT Count(*) AS 'total' FROM Bookings WHERE booking_date ='{$booking_date}' AND booking_slot = '9am'"; $result = mysqli_query($conn, $query) or die(mysqli_error($conn)); $num = $result->fetch_assoc(); If ($num['total'] == 0) { echo "<script> document.getElementById('9amTimeSlotRadioButton').disabled = false; </script>"; } else if($num['total'] > 0) { echo "<script> document.getElementById('9amTimeSlotRadioButton').disabled = true; </script>"; } } ?> My problem is that I cant get the Javascript line within the if statement to execute and disable/enable the related 9am radio button. Upon research into this, I have recently found out that it is not possible to do this with just Php and JavaScript, as php runs serverside and javascript runs client-side and Ajax would be needed here. So, im in a spot of bother now as one of the main selling points of this project was to be able to get this functionality working. I have a massive favour to ask of you guys, could you chime in and guide me on how to implement this functionality by using Ajax? I have zero experience in the language so I really dont know where to start. Any input at all on this topic would be much appreciated. Thanks in advance guys, Dave Ireland.
-
hello every one.... Can any one plz help me how to detect mobile device brand like samsung, nokia or micromax uisng php or javascript.... Any help will be greatly appreciated.... Thank you.. :)
- 2 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
hello eveyone.. How can i pass values from one page to another using javascript.. I can do it using php but I need in javascript or jquery... suppose take this as an example... <script src="myscript.js?uid=123"></script> if the above step is possible then plz help me out.... IF NOT THEN the second way i want is <script src="myscript.php?uid=123"></script> If the above code doesn't have script tag then i can access the value but tthe <script> tag is making me impossible to do it...... I have used this step to access the value from the above code but it shows nothing... <?php $val = $_GET['uid']; echo $val; ?> Any help will be greatly appreciated... Thank you in advance...
-
I need a js gallery that automatically loads a main photo and I'm hoping someone can point me in the right direction to find one. Currently I'm using http://www.dynamicdrive.com/dynamicindex4/thumbnail2.htm But my issue is that this code doesn't load a photo until an image is clicked or you hover over it and I want one that loads a chosen photo automatically. (I have a db table with the photos info in it) Thanks for any help or pointers SJ
-
Hi, I need help getting this thing to work, I'm not sure on how to $_GET[] data after a fragment in the URL. I've seen it used on websites before, for example: example.com/#home?q=test A working example is: http://craftland.org/#map&p=aether This is the code I'm using for the pages: http://pastebin.com/vAHppEyr Any help would be great! Thanks, Kez.