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

Hi,
I want to change visibility of relevant button (like to hide it), per given relevant values on the page. How?

<input type="button" id="butt_p4" onclick="openPopup4();" style="height:23px; width:97px; visibility:visible" value="删除照片" runat="server" />

Open in new window

0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I got elements like this:

<input type="text" class="form-control" id="form_mobile" autocomplete="off" name="form_mobile" required maxlength="8">
<input type="password" class="form-control" id="form_passcode" autocomplete="off" name="form_passcode" required maxlength="6">

Open in new window


The code below seems doesn't work. Any comment to make it work in one liner?

$("#form_mobile #form_passcode").on("keypress", function (e) {
        return e.which !== 13;
    });

Open in new window


Thank you.
0
I am using the below code to create an Ajax DataTable. I want to make a row clickable, and have it open a URL using data from one or more of the columns. So, if there is a row with 2 columns, ID and CarType, and that row is clicked, I want the browser to go to the follwing URL when the row is clicked: www.myshop.com/cars.html?ID=77&CarType=Chevy

This works fine for the first load, but if you perform a search, or the contents dynamically change  and the table is re-drawn, it fails. Can someone please assist?

	$(document).ready(function(){
		searchCars();
	});
	function searchCars() {
		 $('#carsTable').DataTable().destroy();

		// clear the search results
		$("#carsTable tbody").empty();
		// search criteria when form is submitted
		var carType = $("#carType").val();
		var carColor = $("#carColor").val();

		// url to php
		var url = "CarTypes.PHP";

		// argument(s) to add to the url
		url += "&carType=" + carType;
		url += "&carColor=" + carColor;

		var carTable = $('#carsTable').DataTable({
			"order": [
				[ 0, "desc" ]
			],
			"BAutoWidth": true,
			//"stateSave": true,
			"bFilter": false,
			"ajax": url,
			"sAjaxDataProp": "DATA",
			"processing": true,
			// export button 
			"dom": 'Blfrtip',
			"columnDefs": [
				{"visible": false,"targets": [1]}
			],
			buttons: [
			{
			extend: 'collection',
			text:'Utility',
			titleAttr: 'Utility',
			autoClose: true,
			className: 'btn btn-primary btn-xs',
			buttons: [
			'colvis',
			'copy',
			'excel',
			

Open in new window

0
I have this website:
https://goo.gl/iwpDzp


On touch screen laptops, the navigation will not expand on hover.

This is normal behavior: https://www.useloom.com/share/d4e16705a32c4a28abd238219778ad2d

When you are on a touch screen laptop using the same operating systems and browsers as a regular laptop, the menu will not hover. This is driving me mad and I cannot figure out how to fix it. Any help is appreciated.
0
We have an add that has been working for months, maybe a year. Recently an issue has arisen.

See this code:
function chk_vals() {
			if (ac == "l") {
				jj = confirm("Log Out will lose all data entered. OK?");
				if (! jj) {
					return false;
				}
				document.st.action = "logout.php";
				return true;
			}	
			if (ac == "c") {
				jj = confirm("Cancel will lose all data entered. OK?");
				if (! jj) {
					return false;
				}	
				document.st.action = cancpg;
				return true;
			}	
			if (document.st.pn.value == "" || document.st.padr.value == "" || document.st.city.value == "" || document.st.zip.value == "") {
				alert("Minimum of property name, address, city & zip required.");
				return false;
			}

Open in new window


Under very specific circumstances, even when there are values in all of the four form fields, pn, paddr, city & zip, the alert occurs.

3 people have tested this, all using FireFox. The problem NEVER occurs for me. It always occurs for person B. For person C, they updated Java on thee computer (all Windows computers), they had been told that Java needed updating. When they did that, it now works.

Is Java used by FireFox in Windows 10 environment? NO Java is used in the web app (all Javascript, php, mySQL, html, Jquery).

Thanks
0
I am using jQuery Datables with Ajax, so my rows are created dynamically when the datatable loads. Does anyone know how I can make the row, or a column clickable? I'd like to make it so when a user clicks a row, or one of the items in a column it links them to another page. In the URL they click, I will need to include data from one of the columns in that row. For example, if someone clicked the first row below, I'd want to send them to a url: www.myshop.com/newcar.html?ID=77

ID     Carname    Cartype
-------------------------------------
77     carA            chevy
76     carB            dodge
0
Hello
I am trying to declare a global javascript variable that I can use anywhere on the page. However, when I click on the button to open the action window it shows as 'undefined'.

I declared the variable in the head section like thus:
var ref;

Open in new window

I have posted my code and would be grteful if someone could help me correct this. Many thanks

// get the clicked row's data and initialize the input fields.
var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', acteditrow);
activity = dataRecord.activity;
ref = dataRecord.item;
alert(ref); <--- THIS WORKS

if (activity == "New Intake") {
  $("#rack").val(dataRecord.rack);
  $("#row").val(dataRecord.row);
  $("#column").val(dataRecord.column);
  $("#bay").val(dataRecord.bay);
  $("#size").val(dataRecord.size);
  document.getElementById('destdate').value = dataRecord.destdate;

  // show the popup window.
  $("#actionWindow").jqxWindow('show');
}

Open in new window


HTML FURTHER DOWN THE PAGE SHOWING AS UNDEFINED IN THE ACTION WINDOW

<div>You are actioning item: <script type="text/javascript">ref</script></div>

Open in new window

0
Hi Experts,

I'm building a website for a music studio, which is not a one-pager, within WP.

When the visitor clicks on the music player, my client wants to have a play list playing while the visitor goes to other pages. Is there a good plug-in for that? I assume that I need a pop-up window?

Thanks.
0
need a datagrid with horizontal and vertical scrol, the header fixed and and also 2 columns!

You guys
0
I have a form where the user sets a few decimal fields and if the user tabs through the fields the 'total' field calculates all the fields together and gets set and everything works fine but if they use their mouse this is where my troubles begin. I know it is because of the keyup in my function but I wanted to know if there is something else that I can use like something similar to onblur() maybe? I am new to javascript and jquery so I have no clue so any advice would be great.

Here is my code...
<%--Being used for generating Travel item cost values for the Total--%>
<script type="text/javascript">
    $(document).ready(function () {
        $(".toCalculate").keyup(function () {
            var total = 0;
            $(".toCalculate").each(function (index, item) {
                temp = parseFloat($(item).val());                
                if (isNaN(temp))
                    temp = 0;
                total = total + temp;
            });
            $(".total").val(total.toFixed(2));            
        });
    });
</script>

Open in new window


Thanks for the help!!!
0
Free Tool: SSL Checker
LVL 9
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

I have a select input on a page and I want the user to select an option. When they select an option, I coded it where they will be forwarded to another page with a different form. I would like to carry over their selection to the "value" of an input field in the new form. Can someone help me execute this? I'm assuming it can be done somehow with javascript but not sure how.

This is the select button code on the first page:
<select type="text" class="service-list form-control" data-placeholder="Select Option" onchange="location = this.value;">
	<option value="new-form.html">Apple</option>
	<option value="new-form.html">Orange</option>
	<option value="new-form.html">Watermelon</option>
</select>

Open in new window


This is the input code on the page the user is forwarded to. Let's assume the user selected the "Orange" option in the above example.
<div class="form-group">
	<input class="form-control" name="option" id="option" type="text" value="Orange" disabled>
</div>

Open in new window

0
Thank you for looking at my question,

I think it's fair to say I'm not really sure what I'm doing, but having read some stuff on here and from other sources I've cobbled this together - it doesn't work, can anybody help me put it right.

I have a php form with three input boxes main, rtd and combined (mimics production paperwork). I want, as the user tabs away from main or rtd, to sum the values of main and rtd and display the result in combined - I'm sure this is possible  I just don't know how to achieve it.


								echo '<table>';
									echo '<tr>';
										echo '<td colspan="4">Strain Gauge Before Stretching</td>';
										echo '<td>MT Strain Gauge</td>';
										echo '<td align="center">Main</br><input type="text" id="main" OnChange="jsCalculate()"/>&Omega</td>';
									echo '</tr>';
									echo '<tr>';
										echo '<td>MT Strain Gauge RTD</td>';
										echo '<td align="center"><input type="text" id="rtd" OnChange="jsCalculate()"/>&Omega</td>';
										echo '<td align="center">Combined</br><input type="text" id="combined"/>&Omega</td>';
									echo '</tr>';
								echo '</table>';
							echo '</td>';
							echo '<td width="50%" align="center">';
							echo '</td>';
						echo '</tr>';
					echo '</table>';
				echo '</td>';
			echo '</tr>';
		echo ' </table>';
	}
?>
<script language="javascript">
	function jsCalculate(){
		var SGMain = document.getElementbyid("prestretchmain").value;
		var SGRTD = 

Open in new window

0
Perhaps I am over-thinking this but what I need to do is see what the time difference it is from the start session time (1 minute) subtracting the current time.
<script type="text/javascript">
var mySessionTimer;

@functions {        
    public int PopupShowDelay
    {
        get {
            DateTime currentSetTimeout = DateTime.Now.AddMinutes(HttpContext.Current.Session.Timeout);
            DateTime currentServerTime = DateTime.Now;
            TimeSpan duration = (currentServerTime.Subtract(currentSetTimeout));

            return 60000 * (int)duration.TotalMinutes;
        }
    }
}

function callJSSessionTimer() {
    var sessionTimeoutWarning = @PopupShowDelay;
    var sTimeout = parseInt(sessionTimeoutWarning);

    mySessionTimer = setTimeout('SessionEnd()', sTimeout);
}

function SessionEnd() {
    clearTimeout(mySessionTimer);
    window.location = "/Account/sessionover";
}

@if (userInfo != null)
{
    if (userInfo.chosenAMT == "True")
    {
        @:callJSSessionTimer();
    } else
    {
        @:clearTimeout(mySessionTimer);
    }
} else {
    @:clearTimeout(mySessionTimer);
}
</script>

Open in new window

So for the value for duration is -00:01:00 which technically is correct since currentSetTimeout is 1 minute and it gets todays date/time which is a minute away since its subtracting it fromcurrentSetTimeout.

So the point of all of this is to keep track of the remaining session time when the user jumps from page to page. Currently when the user goes to another page, it resets the time and its not accurate.

How can I go about doing this the way I need it?
0
Hi E's,
I Have 3 buttons and a Materialize Modal that contains a HTML Select with Four options to choose from. 0 by default and 1, 2, and 3, and each number between 1 to 3 are associated to each button.
The objective is, when I click in any button, open the Modal and change the select view for the correspondent number.
I try change the selected with jQuery in this way:
$("#numbers[value=3]").attr("selected", "selected");
but not work.
In attach image you can see what appear regardless of which button I click.Modal view
<!DOCTYPE html>
 <html>
   <head>
     <!--Import Google Icon Font-->
     <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
     <!--Import materialize.css-->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.1/css/materialize.min.css">
     <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
   </head>
   <body>
<a class="waves-effect waves-light btn b1">button one</a>
<a class="waves-effect waves-light btn b2">button two</a>
<a class="waves-effect waves-light btn b3">button 333</a>

<!-- Modal Structure -->
  <div id="modal1" class="modal">
    <div class="modal-content">
      <h4>Header</h4>
  <div class="input-field col s12">
  <select id="numbers">
    <option value="0" selected>Choose your number</option>
    <option value="1">one</option>
    <option value="2">two</option>
    <option value="3">3333</option>
  </select>
  

Open in new window

0
I have a Single Page App and I want to scroll to another section from a link on my landing page to another section.  What in your opinion is the best way to do that with current technology?  Javascritpt, Jquery, Other??  And how.
0
I updated node and npm and now yo is not working. I installed it in many ways including sudo npm install -g yo.

It does install and runs the yo doctor. Everything checks out. But when I type yo doctor, it says

-bash: yo: command not found

Im wondering if it has to do with my path and node. I even tried to brew link node and have done many steps. Not sure what else to do so asking the experts!

Thank you all.
0
Hi Guys,
I send json data from my server to the view in MVC project.

Here is the link I send as a json:
dataCell.textCell = "<a onmouseout='HideFlyOut()' ;="" class='theme_color' onmouseover='ShowFlyOut('" + encryptedRowPass + "') href=\documentviewer.aspx?" + encryptedValue + "'<i class='fa fa-paperclip fa-flip-horizontal fa-2x theme_color'></i></a>"

Open in new window



Now in my UI side I'm getting this data which is one row and parse it to json:

 var sendDataRowsToView = JSON.parse(datarows)

Open in new window


Then I"m trying to place this data into a <td> in my dom:

 tableBody.append('<td> + sendDataRowsToView + </td>')

Open in new window



I'm getting the data and all works fine but it doesn't bind it to the dom:

Like I'm expecting to see for exmaple:
<td><a></a></td> which bind all the link from the server, but for some reason I can't see this data in my dom.

what am I doing wrong?
0
I have a form that posts via javascript / jquery / ajax

I am trying to validate some fields server side before actual submission I was doing this to set the variable

myVar=$('#myVarFormID').val();

Open in new window


when I check the console, my variable is set appropriately and shows as intended, but when I go like this after setting it
nextFunction(myVar);

Open in new window


The function thinks the variable is [htmlInputElement]

I dont understand why the output shows fine but the script function wont take it in.  Is there something extra I need to do to pass this form element into a different function?
0
Oh dear guys!
I Need to embed PDF in a modal window for terms aceptance of use of a portal.

please you experts!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 4
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Hello, Experts,

I built a PHP script that queries a database and outputs the results in JS/HTML form. If you could review the code below, I need help how to make the result field URL clickable.

Example:

Name: John Doe
URL: http://google.com

When results display for John, he is able to see the result set for his name and click on http://google.com

Let me know if you need further clarification.

<?php
//fetch.php
$connect = stuff
$output = '';
if(isset($_POST["query"]))
{
 $search = mysqli_real_escape_string($connect, $_POST["query"]);
 $query = "
  SELECT * FROM emp_details 
  WHERE dept LIKE '%".$search."%'
  OR fname LIKE '%".$search."%' 
  OR lname LIKE '%".$search."%' 
  OR pkid LIKE '%".$search."%' 
  OR url LIKE '%".$search."%'
 ";
}
else
{
 $query = "
  SELECT * FROM emp_details;
 ";
}
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
 $output .= '
  <div class="table-responsive">
   <table class="table table bordered">
    <tr>
     <th>pkid</th>
     <th>fname</th>
     <th>lname</th>
     <th>department Code</th>
     <th>url</th>
    </tr>
 ';
 while($row = mysqli_fetch_array($result))
 {
  $output .= '
   <tr>
    <td>'.$row["pkid"].'</td>
    <td>'.$row["fname"].'</td>
    <td>'.$row["lname"].'</td>
    <td>'.$row["DEPT"].'</td>
    <td>'.$row["url"].'</td>
   </tr>
  ';
 }
 echo $output;
}
else
{
 echo 'Data Not Found';
}

?>

Open in new window

0
I've been using an iframe to embed content from a 3rd party vendor for over a year now but recently, particularly in Chrome, the content on the page is flashing and not fully loading, ever, so it seems. I haven't changed my code (see below) so I'm not sure what the problem is. I'm researching solutions but they all seem very complicated at that point, if they would even work. Some involve php and I'm not familiar with that AT ALL so I don't know if that is even an viable option. Please help?

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="SFATouchTasks.aspx.cs" Inherits="SFATouchTasks" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <style type="text/css">
        .page
        {
            width: 1150px;
            height: 100%;
        }        
        .header
        {
            background: #FFF;
            width: 100%;
        }        
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <div id="divEmbed" style="height: 300px;">
        <iframe id="ifm" name="ifm" width="100%" height="300%" frameborder="0" src="http://x.x.xxx.xxx:xxxx/app/main#/dashboards/589e1fed677202f430000031?embed=true"
            scrolling="auto" style="float: left;"></iframe>
    </div>
</asp:Content>

Open in new window

0
Hello all,

The following function is being called by a button ‘onclick’. However, it submit the ‘Form’ even if cancel is clicked!!!
What is the problem?

Kind regards

Abiel M de Groot

<button class="Part_SubmitBUTT" onclick="SubmitPArtesForm()">Are you sure you want to do this?</button>

-------------------------------------------------

function SubmitPArtesForm() {
  if(confirm("Are you sure you want to do this?"))
        document.getElementById("PartesPendingXX").submit();
  else
    return false;
}
0
<div id="myDiv" contenteditable="true"></div>

<div id="arrowBox" style="display:none;">Some buttons Here</div>

Now i want to change display block of arrowBox div when select some text in myDiv..

Please Help me

Thanks
0
Thank you for looking at my question,

I have a user input form (php) that has some javascript validation which should, if the conditions are met, assign a value to a hidden form element but it isn't working and I can't see why.
	<form name="Form1" action="Forms/Section1.php" method="GET" onSubmit="return jsValidate()">
		<input type="hidden" name="StockItem" />

Open in new window


The javascript validation looks like this
if (z.length == 23){
	if (z.slice(0,2) == "VE" || z.slice(0,2) == "SE"){
		
		//alert("So Far So Good");
		
		document.getElementById("StockItem").value = 1; //Full Build
		alert (document.getElementById("StockItem").value);
	} else {
		errorcount++;
		document.getElementById('VECO').style.color='#FF0000';
	}
} else if (checknum==1){
	
	//alert("So Far So Good");
	
	document.getElementById("StockItem").value = 0; //Component
	alert ("Assembly Stock Item: " + document.getElementById("StockItem").value);
} else {
	errorcount++;
	document.getElementById('VECO').style.color='#FF0000';
}

Open in new window


If either of the conditions are met (z == 23 characters starting VE or SE, or checknum == 1)  then, when it's not commented out, the "So Far So Good" alert appears on the screen but the following
alert(document.getElementById("StockItem").value);

Open in new window

doesn't
and no value is assigned to the StockItem element - as can be seen in the address of the php page the data should pass to
http://xx.xx.xx.xx/ed1/Forms/Section1.php?StockItem=&Meter=1000&ProdnOrder=553456789&SalesOrder=9999&SerialNo=&VECode=VE884S05E0G0T01D0004000

Open in new window


What am I missing?
0
I have a div tag "tab-hidden" inside my master-page.aspx file and i am including my master-page in all my pages present in my project. But the issue is i have to hide that div tag from some pages in my project.

 <div class="tab-hidden" style="margin-top: 60px; margin-left: 203px;">  
         <div class="tabbing" id="ipi1">
             <a href="Client_PlaningInformation.aspx" onclick="landingdetails('ipi')">
               
                 Important planning information
            </a>
         </div>
         <div class="tabbing" id="ots1">
             <a href="Client_OrderYourStand.aspx" onclick="landingdetails('ots')">
                
                 Order Your Stand Services
             </a>
         </div>
         <div class="tabbing" id="marketing1" runat="server">
             <a href="#" onclick="landingdetails('marketing')">
               
                 Marketing
             </a>
         </div>
     </div>

Open in new window

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.