Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

JavaScript

120K

Solutions

41K

Contributors

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and  in almost every mainstream web browser.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hello,

Could someone please help me with the attached HTML file?
I am trying to create a 'from validation' with a popup message to validate the FIrst Name field. Please see my form tag:

<form name="myForm" action="message.html" onsubmit="return CheckForm(myForm)" method="post">

and the details for the fields I'm trying to validate. (Just trying First Name to start with)

First Name: <br><input type="text" name="firstname"><br>
Last Name:  <br><input type="text" name="lastname"><br>
Address:    <br><input type="text" name="address"><br>
Phone:      <br><input type="text" name="phone"><br>
Email::     <br><input type="email" name="email"><br>

My Script tag is which is in the head section:

<script>
      function CheckForm(MyForm)
      {
            if (MyForm.firstname.value == “”)
            {
               alert(“You must enter a name”);
               return false;
            }
            return true;
      }
</script>
test.html
0
Hi, I'm trying to recreate this table: http://www.magickitchen.com/cart/cgi/nutri_table.cgi?cmd=display_nutri_table&css_id=nutrition-table&sku=97124  we used Footable to get that working. It collapses when it's in a smaller view and you can open things by clicking on the plus sign.

Here's the new page: http://dev2.magickitchen.com/cart/cgi/nutri_table.cgi?cmd=display_nutri_table&css_id=nutrition-table&sku=97124 

On that page, user name:pepe  password:BobTheBuilder45!!

I've included the links to footable css and javascript, and checked that those files are there, but I am stuck, it's just not working. Can you help? Thanks.
0
Thanks Robert this hint
Hallo
I try to execute a javascript on a Windows and I use Firefox Scratchpad editor to lerning this language. My problem I get an error, if I execute following script. I need your help and hope what is a simple beginner error.


/*
 * This is a JavaScript Scratchpad.
 *
 * Enter some JavaScript, then Right Click or choose from the Execute Menu:
 * 1. Run to evaluate the selected text (Ctrl+R),
 * 2. Inspect to bring up an Object Inspector on the result (Ctrl+I), or,
 * 3. Display to insert the result in a comment after the selection. (Ctrl+L)
 */

<script>
alert('Hallo Welt');
</script>
/*
Exception: SyntaxError: expected expression, got '<'
@Scratchpad/1:10
*/
/*
Exception: SyntaxError: expected expression, got '<'
@Scratchpad/1:10
*/
0
Hi EE.

I have built a website using Mobirise and now what I want to do is to enable the site to accept comments from people and also display them on the page on the section COMMENTS, now the problem is that I want the comments to use the themes format but the problem with that is that the javascript produce and error if I take the entire DIV section that produce this comment style so that it will be applied to each and every comment. Please check the site and click on the Piracy Impact and check the comment section to see how I want all of my comments to show like. I have 2 php files which one is for retrieving the comment and the other for retrieving the name, this helps me to keep the style but this only works for the first comment, then the rest just displays bellow the first comment and without separating the retrieving process the name is not displayed in a correct stye.

Bellow are the codes that I use to retrieve data:

1) Display Comments

   
<?php
    $con = mysql_connect("xxxxx","xxxxx","xxxxx");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("ndlelabyte",$con);
    $article_id = $_GET['id'];
    $query = "SELECT * FROM `ndlelabyte`.`messages` WHERE `articleid` =$article_id LIMIT 0 , 30";
    $condolencey = mysql_query($query);
    while($row = mysql_fetch_array($condolencey, MYSQL_ASSOC))
    {
    $cond = $row['comments'];
    echo "<p>$cond</p>
    ";
    }
    mysql_close($con);
    ?>

Open in new window


2) Displaying the name is the similar code as above but this time I point/retrieve the name.

On my page I have this under the comment section.

   
<div class="mbr-testimonial card">
                            <div class="card-block"><p>
                        <?php include("display_comments.php"); ?></p></div>
                            <div class="mbr-author card-footer">
                                <div class="mbr-author-name">
    <?php include("display_name.php"); ?>
    </div>
    </div>
    </div>

Open in new window


Now as you can see doing this will only show the last comment but if I had placed the DIV inside the php files which retrieves data from a MySQL database I wouldn't have a problem because each message was going to be displayed as it should be with the style I want to keep.

How can I solve this problem?

The site is HERE
0
I have a checkbox on a webform. I am using javascript to toggle a <div> hidden / show depending on the checkbox being checked. I need to determine whether the checkbox is checked in the codebehind. If I add runat="server", the javascript doesn't work, but I cant get the state of the checkbox from the codebehind. Anyone have an idea how to fix my issue. I'm using vb.net for code behind.

<input type="checkbox" id="cb01" />
0
Hi experts, I wanted to know how server pc handle the multiple clients while accessing the data at the same time. I am beginner developing web programming, and have a little background of vb6 language. Here what I exactly wanted to know, I have a server side Asp named, GetProduct.asp When in terms of response to the client upon the request, does it matter the response of it base on the number of clients having a request? Since I've only one GetProduct.asp How could the server handle it? Let's say, for example 1,000 clients who have requested to inquire the product at exactly the same time, does the response of the server will cause a delay because of the multiple request? if it could cause the traffic because of the numbers of request, should I need to assign GetProduct.asp per client? I hope you (experts) can give some insight about this. Thank you!
0
OK... I am a simpleton in JavaScript.

I was given a viable solution from an expert with a link to JS Fiddle

How do I apply that on a .Net aspx page which has a masterpage?

Does it go at the top?
Bottom?

Does it need anything added onto the front end of the tags?

There is HTML Code
password :
<input type=password id=pwd1> again
<input type=password id=pwd2>
<br>
<input type=checkbox id=chkUpper>Upper?
<br>
<input type=checkbox id=chkLower>Lower?
<br>
<input type=checkbox id=chkSpec>Special?

Open in new window


Here is the script code
function chkPassword() {
  var c;
  var pwd1 = $("#pwd1").val();
  var pwd2 = $("#pwd2").val();

  $("#chkUpper").prop('checked', false);
  $("#chkLower").prop('checked', false);
  $("#chkSpec").prop('checked', false);
  $("#chkMatch").prop('checked', false);
  $("#btnSubmit").prop('disabled', true);

  console.log(pwd1 + "-" + pwd1.length);

  for (i = 0; i < pwd1.length; i++) {
    c = pwd1.charCodeAt(i);
    console.log(c);
    //65-90:A-Z
    if ((c >= 65) && (c <= 90)) $("#chkUpper").prop('checked', true);
    //97-122:a-z
    if ((c >= 97) && (c <= 122)) $("#chkLower").prop('checked', true);
    if ((c < 65) || (c > 122) || ((c > 90) && (c < 97))) $("#chkSpec").prop('checked', true);
  }
  $("#chkMatch").prop('checked', (pwd1 == pwd2) && (pwd1 != ""));
  var canSubmit = $("#chkUpper").prop('checked') && $("#chkLower").prop('checked') && $("#chkSpec").prop('checked') && $("#chkMatch").prop('checked');
  $("#btnSubmit").prop('disabled', !canSubmit);
}

$("#pwd1").on("keyup", function() {
  chkPassword();
});

$("#pwd2").on("keyup", function() {
  chkPassword();
});

Open in new window

0
Hi,
It seems event below, cannot be fired, after the change of the value of TextBox.
                <asp:TextBox ID="tb_construct_area_size"
                    width="170px"
                    Font-Names="Times New Roman" 
                    Font-Size="11pt" 
                    Font-Bold="true"
                    ForeColor="Black"
                    OnTextChanged="area_changed"
                    runat="server" />
                    ...
        protected void area_changed(object sender, EventArgs e)
        {
            if (Convert.ToInt32(tb_construct_area_size.Text) < Convert.ToInt32(tb_area.Text))
            {

Open in new window

0
Hello Experts,

In WordPress I have a basic menu that has my pages, but how can I  changes so that instead of permalinks it use custom such as javascript:changepage(pageID);

Do I need to do a custom Function to override wp_nav_menu?
0
Hi Guys,

I am trying to loop through my table with javascript:

Here is my dom:
Note: this table is getting 5 rows:
<table class="table table-bordered" id="tableid">
    <thead>
        <tr>
            <th>Itemlookup</th>
            <th>Description</th>
            <th>Option</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    <input type="text" value="@item.ItemLookupCode" id="itmlookupid" />
                </td>
                <td>
                    <input type="text" value="@item.Description" id="descid" />
                </td>
                <td>
                    <a id="editme" onclick="getRows()">edit </a>
                    <input type="hidden" value="@item.ID" id="iddata" />
                </td>
            </tr>
        }
    </tbody>

</table>

Open in new window


Now this is what I'm doing in my javascript code:

 function getRows() {
            var table = document.getElementById("tableid").tBodies[0]
            debugger;
            for (var i = 0; i < table.rows; i++) {
                debugger;
                var rownum = i;
            }

        }

Open in new window


I'm trying to loop through the table and get number of rows. The issue is that it loops once and finish the loop.
Usually I do these things with jquery which is very easy, but I would like to do it with javascript this time.

Please, any help.
0
function findMaxRepeatCountInWord(word) {
  
  // Break up individual words into individual letters.
  var a = word.split('');
  
  // Count the instances of each letter
  var counted = a.reduce(function(allChars,char){
    if (char in allChars) {
      allChars[char]++;
    } else {
      allChars[char] = 1;
    }
    return allChars;
  }, {});
  
  // Iterate all the counts and find the highest
  // Return this word's max repeat count
  var totals = [];
  for (var key in counted){
    totals.push(counted[key]);
  }
  return totals.reduce(function(x,y) {
    return (x > y) ? x : y;
  });
}


function findFirstWordWithMostRepeatedChars(text) {
  var maxRepeatCountOverall = 0;
  var wordWithMaxRepeatCount = '';
  text.split(" ").forEach(function(word) {
    var repeatCountForWord = findMaxRepeatCountInWord(word);
    if (repeatCountForWord > maxRepeatCountOverall) {
      maxRepeatCountOverall = repeatCountForWord;
      wordWithMaxRepeatCount = word;
    }
  });
    
      
  return wordWithMaxRepeatCount;
}

Open in new window

0
 /*this code is work  for image how can i make it work for video for code section below
	      var img2 = document.createElement('img');
              img2.src = "http://www.mykohsamui.com/wp-content/uploads/2017/08/sunset-samara-samui.jpg";
              infowincontent.appendChild(img2);

      */ 


               var img2 = document.createElement('video');
              img2.src = "https://www.youtube.com/watch?v=4BGCpKQTMfo";
              img2.autoPlay = true;
              infowincontent.appendChild(img2);
               

Open in new window

0
Hi Experts,

I am working on http://www.southerntime.ca/about/ and you will see that I have a fixed header with a music player as dropdown. You will also note that everythign below the top blue line scrolls.

My clien now would like the music to continue nonstop as the visitor changes pages, and I am wondering how can I approach this: iFrame, separate divs, or other.

iFrame - with this I am thinking I need to iFrame the scrolling content, but how can I set the width and height of it to 100%, especially considering that the header expand in height when opening the player.

Separate DIVs - I was looking at https://wordpress.stackexchange.com/questions/177507/how-to-merge-all-my-pages-into-one-while-keeping-a-menu-bar  and have the following code, but I am not quite sure how to access the featured image and make it look the way that it is now. I guess I dont know how to assess the required element

<?php
/*
 * Template Name: Southern Time
 */

//This template converts all pages to one page-site, so that music does not stop
//playing while changing pages.
?>

<?php get_header(); ?>	

<?php
    $pages = get_pages( array(
        'sort_column' => 'menu_order', // allows you to order pages using menu order under page attributes
    ) );

    foreach ( $pages as $page ): 
        
        print_variable($page, 'page');
        
        $content = $page->post_content;
        if ( ! $content ) // Check for empty page
            continue;

            

Open in new window

0
Hi,

Any  idea about how to increase Internet Explorer 10 ReceiveTimeout (Server response time) programmatically (java , jquery , ajax)  apart from below settings.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings
0
I have a .net page that has a master bage

On the .net aspx page I have 4 html input checkboxes

I also have two input textboxes and a .Net button

What I want is that in textbox 1
As a person types... and gets a "CAPS character that the chkCaps input gets checked
Lowercase character triggers chkLower and special character chkSpec

after the person types in second box...and it matches... chkMatches appears and is checked

btnSubmit becomes visible
0
I am trying to run the code below
    $(function() {
        var params = {
            "api_key": "{xxxxxxxxxxxxx}"
            // Request parameters
            "StationCode": "{string}"
        };

        $.ajax({
            url: "https://api.wmata.com/Rail.svc/json/jStationParking?StationCode=A09",
            type: "GET",
            contentType: "application/json"
        })
        .done(function(data) {
            //alert("success");
            console.log("success" + JSON.stringify(data) );
        })
        .fail(function() {
            console.log("error");
        });
    });

Open in new window

but I get this error:
Error
0
Hi Experts,

Can any one tell me why I cannot properly center #divPlayerArrow and why do they jump left and right when clicking on them?

Thank you.
0
Good morning. I have a snippet of javascript code that basically just turns on a new text box if a drop down box is selected. The code is specific to a certain number selected, so if 'A.0022684.1.1.4' is selected, it displays a new text box.

if (value == "A.0022684.1.1.4"){
          showElement(thatObject.name);

What I'd like to do is instead of using a specific number, Id like to use a wild card...so that if and number selected starts with 'A.' then the new text box will display. I'm no javascript whiz so I was hoping a wildcard could be used somewhat easily.

Thanks
0
Hi Experts,

I have two drop downs.
First dropdown vals:
ExportPDF/CSV
ExportPDF
second dropdown vals:
pdf
csv

when i chosse first drop down val as->ExportPDF/CSV
second drop down should display both values pdf,csv

when i chosse frist drop down val as->ExportPDF
second drop down should display only pdf.

Can some suggest me how to do using javascript.

Thanks,
0
I am at a loss. I am using Nick Stakenburg's LightView and can't seem to solve why I am having a problem.
I have a login form in a LightView modal window. When the user submits the form, I need the modal window to close, the information sent to a login.php program, and the window that is parent to the modal to be refreshed.
There is a login check in the header that needs to change the button display when the user is logged in. I've been using the login routine or a few years, so there is no problem there. My problem is the LightView modal is not going away and I don't know how to refresh the page. I could do it with javascript in the login.php script, but it seems that I should be able to do both within the form script that displays in the modal.

I am calling LightView inline like so:
<a class="lightview btn btn-success" data-lightview-title="Login" href="scripts/loginform.php" data-lightview-options="skin: 'light', border: {size: 15, color: '#FFFFFF', opacity: 1 }, width: 600, height:399" data-lightview-caption=""><i class="fa fa-unlock-alt"></i>&nbsp Log in</a>

Open in new window


Between the html5 body tags is this:
      <div style="float:left; width:240px; font-family:Arial, Verdana, sans-serif; color:#000000; text-align:center; font-weight:600;">
         <form id="LoginForm" method="post" action="../login.php" onsubmit="return MoveOn()">
            <br /><br /><br />
            <label for="user">Username or Account Code:</label><br />
            <input 

Open in new window

0
When the usr uses the my from button it opens an iframe and has the button sample one which opens a form from authrize.net credit card company.

what i am trying to do is open the button sample one when the form is loaded.

My script and code

When i use f12 console it get this message when is use the second button. When testing on my local computer.

DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337
File: sample4.aspx
<script>
        $(".inline").colorbox({
            inline: true,
            opacity: 0.5, // overlay a bit less dark
            innerWidth: 640,
            innerHeight: 390
        });

        function myfunction() {
            document.getElementById("LinkTo").submit();
        }
    </script>
  <form id="form1" runat="server" onsubmit="myfunction()">
  <div>
    
    <p><a class='inline' href="#inline_content">My Form</a></p>
      <input type="submit" name="test" onsubmit="myfunction()"/>
  </div>
</form>

<div id="myForm" style='display:none'>
  <div id='inline_content'>

       <script>
        $(".inline").colorbox({
            inline: true,
            opacity: 0.5, // overlay a bit less dark
            innerWidth: 640,
            innerHeight: 390
        });

       
    </script>
    <form name="OutputForm" method="post" action="https://test.authorize.net/payment/payment" target="payframe" id="LinkTo" class="ShowForm">
      <input 

Open in new window

0
HI
I HAVE AN AJAX HTNL EDITOR ON A SCREEN
AND I HAVE 3 TEXTBOX WHERE AUTOPOSTBACK = TRUE
ONCE I ENTER ANY BOLD CHARCTERS INSIDE THIS AJAX HTNL EDITOR POSTBACK OF TEXTBOX IS NOT FIRED HOW TO SOLVE SUCH WEIRD ISSUE
below is the design:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="test.WebForm1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link id="MyStyleSheet" rel="stylesheet" type="text/css" href="~/Styles/CssStyles.css" runat="server" />
    <%--<link id="MyAlertStyle" rel="stylesheet" type="text/css" href="~/Styles/sweetalert.css" runat="server" />--%>
</head>
<body>
    <form id="form1" runat="server">
         <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"
            AsyncPostBackTimeout="360000" AllowCustomErrorsRedirect="False">
             </asp:ScriptManager>
        <asp:UpdatePanel ID="sd" runat="server">
            <ContentTemplate>
     <asp:TextBox ID="txt_Year" runat="server"  Height="22px" 
                                                AutoPostBack="true" CausesValidation="false"
                                                OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
        <asp:TextBox ID="Literal_ProbationMemo" runat="server" CssClass="descriptionTextBox"
                                     

Open in new window

0
i have asp.net app and a list of mp3 file in my c: drive. How can use <audio> to open them?
another question is I want to list all of the mp3 in table. For each row, I want to have media play (https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_source_src) , how can I do that?
0
0
Hi Experts,

I am using the AudioIgniter from https://www.cssigniter.com/preview/audioigniter in WP and I am wondering how can I initiate the play action with JS.

For example,
$('document').on('ready', function() {
    //play
});

Open in new window


Any help will be greatly appreciated.
0

JavaScript

120K

Solutions

41K

Contributors

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and  in almost every mainstream web browser.