Link html to another html file [closed] - html

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have 2 HTML files , index.html that have 1 button , and process.html that have function Login() script... when i press the button, it redirect to process.html and process the function Login() automatically ... What must i do ? using a href or what?
index.html
<div class="login">
<div class="fb"><img src="facebook.JPG" style="cursor:pointer;" height="50px" width="250px"/><br></div>
</div>
process.html
<html>
function Login()
{
//code that process login
}
</html>

In index.html you put onclick="location.href='process.html'" at 'img' tag:
<div class="login">
<div class="fb">
<img onclick="location.href='process.html'" src="facebook.JPG" style="cursor:pointer;" height="50px" width="250px"/><br>
</div>
</div>
At process.html you put 'login();' function at the end of login code, you may use jquery document.ready function or body onload.:
<html>
<script>
function Login()
{
//code that process login
}
Login();
</script>
</html>

Related

Upload Many File Using One Input [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 days ago.
Improve this question
I want to upload many files (.png , .pdf , etc) by using one input.
<input type="file" name="files[]" multiple />
This example captures the input result from an input tag that already contains multiple files
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.3.min.js" integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>
</head>
<body>
<input type="file" id="fileInput" multiple />
<script>
$(document).ready(function() {
$("#fileInput").change(function() {
var files = this.files;
for (var i = 0; i < files.length; i++) {
console.log("File " + (i+1) + ": " + files[i].name);
}
});
});
</script>
</body>
</html>

Cors and Onedrive [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I need to look at a file(json) from my html page. This file is on my onedrive and I published it to everybody who have the link. So ss there a way to look at a file from onedrive in my html site? If yes how?
Following the steps on https://msdn.microsoft.com/en-us/library/hh550848.aspx will allow you to accomplish this task.
On the HTML portion of your code, add the and to call the wl.upload function. Below is my code that will allow the use to select the file and upload it to a default folder on OneDrive. In this case, I used "me/skydrive/my_documents"
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Sample</title>
<script type="text/javascript" src="//js.live.net/v5.0/wl.js"></script>
</head>
<body>
<div style="padding: 1em">
<div id="signin"></div>
<label id="info"></label>
<form>
<input id="file" name="file" type="file" />
</form>
<button onclick="uploadFile()">Save file directly (calling WL.upload)</button>
<script>
WL.init({
client_id: 'Your_Client_ID',
redirect_uri: 'Your_Redirect_URL',
scope: "wl.signin",
response_type: "token"
});
WL.ui({
name: "signin",
element: "signin"
});
function uploadFile() {
WL.login({
scope: "wl.skydrive_update"
}).then(
function (response) {
WL.upload({
path: "me/skydrive/my_documents",
element: "file",
overwrite: "rename"
}).then(
function (response) {
document.getElementById("info").innerText =
"File uploaded.";
},
function (responseFailed) {
document.getElementById("info").innerText =
"Error uploading file: " + responseFailed.error.message;
}
);
},
function (responseFailed) {
document.getElementById("info").innerText =
"Error signing in: " + responseFailed.error.message;
}
);
}
</script>
</div>
</body>
</html>
The path "response.data.folders[0].id" is used to select the folder that the user has selected from the OneDrive file picker when WL.fileDialog is called. If you are uploading to a default folder, you would want to omit the file picker and use the JavaScript API.
Reference: https://support.microsoft.com/en-us/office/upload-files-and-folders-in-onedrive-work-or-school-5bd927ad-d186-495c-93e8-7ca116fe7b83

How to execute the html reflecting the changes i have done with PHP? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to change all the occurrences of a word with another word using php. I want my HTML code to reflect the changes I have done accordingly.
<?php
$strhtml = '<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>time</title>
</head>
<body>
<p id="post">Hello, How are you</p>
</body>
</html>';
$dochtml = new DOMDocument();
$dochtml->loadHTML($strhtml);
$elm = $dochtml->getElementById('post');
$c = $elm->nodeValue;
$d= date("H");
if ($d<11)
str_replace("Hello","Good Morning",$c)
?>
You can use $dochtml->saveHTML() function to parse DOMDocument object to html content. This code works for me.
<?php
$strhtml = '<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>time</title>
</head>
<body>
<p id="post">Hello, How are you</p>
</body>
</html>';
$dochtml = new DOMDocument();
$dochtml->loadHTML($strhtml);
$elm = $dochtml->getElementById('post');
$c = $elm->nodeValue;
$d= date("H");
if ($d<11){
$c = str_replace("Hello","Good Morning",$c);
}
$dochtml->getElementById('post')->nodeValue = $c;
echo $dochtml->saveHTML();
?>

HTML: url = <name var> [duplicate]

This question already has answers here:
Can a JavaScript variable be used in plain HTML?
(7 answers)
Closed 6 years ago.
As href argument, I would like to put a variable.
Instead of:
<p>Go to Google</p>
</body>
</html>
I would like to write something as:
<html>
<body>
var link = "http://www.google.com"
<p><a href=link>Go to Google</a></p>
</body>
</html>
You can do something like this:
<html>
<head>
</head>
<body>
<p><a id="some-link">Some link</a> is here</p>
<script>
var link = 'http://www.google.com';
var someLink = document.querySelector('#some-link');
someLink.setAttribute('href', link);
</script>
</body>
</html>
The script tag executes javascript actions. This one specifically sets the href of the given item with the some-link id. The # means "element with the id".
You can try it over here. https://jsfiddle.net/94ct5hvr/
You can do this with angularJS
<html>
<body ng-app="App" ng-controller="myApp">
<p><a href={{link}}>Go to Google</a></p>
</body>
</html>
On the javascript side you can do:
var app = angular.module('App',[]);
app.controller(function($scope){
$scope.link = "http://www.google.com;
});

how to add and remove data into .JSON file [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
In our application we have 4 pages. Each page has 5 check boxs. If I
<--
app flow like this page0 -->page1 -->page4
-->page2 -->page4
-->page3 -->paeg4
go to page 1 and select 2 items,
then go to page 2, and select 4 items,
and after that go to page 3 and select 2 items,
the total count of items selected is 11.
Now, if I now go to page 4, can I somehow store the values from all pages to save.json file which is located under www folder. I am using PhoneGap.
If you are asking if a PhoneGap app can write a JSON file, then the answer is yes. Use the FileSystem plugin to do so. However, if you are just saving a small amount of data, it would be far easier to use LocalStorage.
First you need to create an array , store this array in localStarage, like got to page 1 store two value in array and update your localStorage value on every page on selection, on last page write this localStorage value in file using org.apache.cordova.file plugin. I have done example, you can manage as your rquirement.
a.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page" id="page_a">
<div data-role="header" class="">
<h3>Fruit</h3>
</div>
<div role="main" id="" class="ui-content">
<div class="ui-field-contain">
<fieldset data-role="controlgroup">
<input type="checkbox" name="apple" id="apple" value="Apple" >
<label for="apple">Apple</label>
<input type="checkbox" name="orange" id="orange" value="Orange">
<label for="orange">Orange</label>
</fieldset>
</div>
Book Order
</div>
</div>
</body>
<script>
var arr_fruit = [];
$("#btn_a").on("click", function(event){
$("input[type=checkbox]:checked").each(function(key){
arr_fruit.push( $(this).val());
});
localStorage.setItem("arr_fruit", arr_fruit);
location.href = "c.html";
})
</script>
<html>
b.html
<div data-role="page" id="page_b">
<div data-role="header" class="">
<h3>Flowers</h3>
</div>
<div role="main" id="" class="ui-content">
<div class="ui-field-contain">
<fieldset data-role="controlgroup">
<input type="checkbox" name="rose" id="rose" value="Rose" >
<label for="rose">Rose</label>
<input type="checkbox" name="sunflower" id="sunflower" value="Sunflower">
<label for="sunflower">Sunflower</label>
</fieldset>
</div>
Book Order
</div>
</div>
<script>
var arr_flow = [];
$("#btn_b").on("click", function(event){
$("input[type=checkbox]:checked").each(function(key){
arr_flow.push( $(this).val());
});
localStorage.setItem("arr_flow", arr_flow);
location.href = "c.html";
})
</script>
c.html
<div data-role="page" id="page_c">
<div data-role="header" class="">
Page A
<h3>Details</h3>
Page B
</div>
<div role="main" id="" class="ui-content">
<p id="fr_title" style="display:none"><h3>Fruits</h3> </p>
<ul data-role="listview" id="list_fruit"></ul>
<p id="fl_title" style="display:none"><h3>Flowers</h3> </p>
<ul data-role="listview" id="list_flow"></ul>
</div>
</div>
<script>
var list_fruit = "";
var arr_fruit = localStorage.getItem("arr_fruit").split(",");
var list_flow = "";
var arr_flow = localStorage.getItem("arr_flow").split(",");
$("#page_c").on("pageshow", function(event){
// Fruits
$("#fr_title").show();
$.each(arr_fruit, function(key, value){
list_fruit += '<li>'+value+'</li>';
});
$("#list_fruit").html(list_fruit).trigger("create");
$("#list_fruit").listview( "refresh" );
// Flowers
$("#fl_title").show();
$.each(arr_flow, function(key, value){
list_flow += '<li>'+value+'</li>';
});
$("#list_flow").html(list_flow).trigger("create");
$("#list_flow").listview( "refresh" );
});
</script>