[Solved] jQuery Adding new option to select element doesn’t pick up the string [closed]

Change: var str = $(‘#country-select’).val() + ” ” + $(“#” + $(“#country-select option:selected”).val() + “-select option:selected”).val(); to: var str = $(‘#country-select, .sub-menu’).val() + ” ” + $(“#” + $(“#country-select option:selected”).val() + “-select option:selected”).val(); jFiddle example You need to trigger the change on both the first and second selects, so $(‘#country-select, .sub-menu’) is needed. solved jQuery … Read more

[Solved] How to get text input and paste it in front of a link using PHP?

<form action=”THE PAGE YOU SENT REQUEST” method=”POST”> <input placeholder=”zoeken” name=”zoaken” type=”text”> <input type=”submit” value=”Submit”> </form> <?php /* Get the text input with $_POST */ $string = $_POST[‘zoaken’]; /* Redirect the page to the new address */ header(‘Location: https://nl.wikipedia.org/wiki/’.$string); You should also check if the text is null, empty or has vulnerability. 0 solved How to … Read more

[Solved] NodeJS, MongoDB : Pass fetched data and display it on HTML

var questions = [ { number: ‘1’, text: ‘question_1’ }, { number: ‘2’, text: ‘question_2’ }, { number: ‘3’, text: ‘question_3’ }, ]; res.send(result, { questions: questions}); In the code above instead of initializing an empty array, I am assuming that I have a pre defined array of questions. In the res.send() part of the … Read more

[Solved] Javascript to check if div has child with that classname [closed]

try the following: $(“.item-card”).click(function() { var itemnume = $(this).find(“img”).attr(“title”); var replaced = itemnume.split(‘ ‘).join(‘_’); if ($(this).hasClass(‘selected-item’)) { console.log() $(“#” + replaced).remove(); } else { $(“#itemcart”).append($(“<div id=” + replaced + “>” + itemnume + “</div>”)); } $(this).toggleClass(“selected-item”); }); https://jsfiddle.net/0tusd19b/ 40 solved Javascript to check if div has child with that classname [closed]

[Solved] How can I make my header smaller if i will scroll down the webpage [closed]

Are you looking for something like this? $(function () { $(window).scroll(function () { if ($(window).scrollTop() > 5) $(“header”).addClass(“small”); else $(“header”).removeClass(“small”); }); }); * {margin: 0; padding: 0; list-style: none; font-family: ‘Segoe UI’;} body {padding-top: 100px;} p {margin: 0 0 10px;} header {height: 100px; line-height: 100px; text-align: center; background-color: #ccf; position: fixed; left: 0; top: 0; … Read more

[Solved] capture image clicked in one page and display the same in another page HTML

Page 1: <%@ page language=”java” contentType=”text/html; charset=ISO-8859-1″ pageEncoding=”ISO-8859-1″%> <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″> <title>Page 1</title> <script type=”text/javascript”> function filename(){ var fullPath = document.getElementById(“image”).src; var filename = fullPath.replace(/^.*[\\\/]/, ”); var fileid = filename.split(“\.”)[0];; window.location.href = “https://stackoverflow.com/questions/37542650/test2.jsp?imgid=”+fileid; } </script> </head> <body> <IMG id=”image” SRC=”images/1.png” width=”100px” alt=”Logo” onclick=”filename();”> </body> … Read more

[Solved] How to put javascript in html file

Following can be a reason for your issue Invalid src path in the script tag Javascript might be disabled in your browser. You have a script error/exception that stopped entire page’s script execution. Maybe you have an Ajax request that won’t work if your open it as a local file protocol. e.g., file:// What can … Read more

[Solved] Position absolute is not relative to its its parent CSS

*{ box-sizing: border-box; } .empty-container { height: 100px; border: 1px solid gray; } .container { height: calc(100% – 100px); border: 1px solid red; display: flex; position: relative; } .component-loader{ border: 1px solid gray; position: absolute; height: 90px; width: 90px; left: 0; right: 0; top: 0; bottom: 0; margin: auto; } .loader-spinner:before { content: “”; margin: … Read more

[Solved] how can i check winners by using jquery [duplicate]

$(document).ready(function() { let gameArray = []; let turn = 1; let gameOver = false; $(“#turn”).text(turn === 1 ? ‘X’ : ‘O’); $(“.smallbox”).click(function() { let squereIndex = $(this).attr(‘id’).replace(‘square’, ”) – 1; if (turn == 1 && !gameOver && gameArray[squereIndex] === undefined) { $(this).text(“X”); $(this).addClass(“X”); turn = 2; gameArray[squereIndex] = 1; } else if (!gameOver && gameArray[squereIndex] … Read more

[Solved] if statement doesnt work when included with two variables

myInput is undefined for your event, you should get the value by adding following line in your eventListener. let myInput= document.getElementById(“myInput”).value; Change your code like following. var input = document.getElementById(“myInput”); input.addEventListener(“keyup”, function(event) { let myInput = document.getElementById(“myInput”).value; for (i = 0; i < objPeople.length; i++) { if (myInput == objPeople[i].studentid && event.keyCode === 13) { … Read more

[Solved] Random number game isnt functioning

First, your JS function isn’t closed properly with an ending bracket }, causing syntax errors. Secondly, you have a character double quote that isn’t supported in the code “ instead of using “, which is also causing runtime errors. Also, you aren’t closing your header tags (<h1>, <h2>) etc. function guessNumber() { var playerGuess = … Read more

[Solved] Change of background using CSS

That would be nice, but no. You don’t need that hard a function, though. Simply attach the background change with the rest of the functionality of the button. I recommend in this case that you just add the background image as css inline with your js, because 6 classes of images can go wrong easy. … Read more