I got AutoIt to work with my router login page. However for our HP Pro Curve Switch.. I can't get it to work...
#NoTrayIcon
#include <ie.au3>
$Address = "http://10.255.96.2/index.html"
$pwd="mypassword"
$oIE = _IECreate ($Address)
_IELoadWait($oIE)
$oForm = _IEFormGetObjByName ($oIE, "maindata")
for $stuff in $oForm
if $stuff.name = "password" and $stuff.type = "password" then _IEFormElementSetValue ($stuff, $pwd)
If $stuff.value == "Login" and $stuff.type = "submit" Then $stuff.click
Next
exit
I get "H:\loginToSwitch.au3" (10) : ==> Variable must be of type "Object".:
Basically the "maindata" is incorect.
Here is the HTML if I right click on the page and view source:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta name=Copyright content="Copyright (c) 2005 HP Networks, Inc. All Rights Reserved.">
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta http-equiv="Pragma" content="no-cache">
<title>HP Networks Web Interface</title>
<script src="/mainjs.js" language=javascript type="text/javascript"></script>
<script language="javascript" type="text/javascript">
//<!--
checkFrame(); // Ensure we are not within a frame
implementLoginFrames('login.html');
document.write('<noframes>');
//-->
</script>
</head>
<body BGCOLOR="#DAE3EB">
<center>
<font color="#008BD1" face="Arial, Helvetica, sans-serif"><B>Please ensure that your browser supports Frames and Javascript, and that they are both enabled.</b></font>
</center>
<script language="javascript" type="text/javascript">
//<!--
document.write('<\/noframes>');
//-->
</script>
</body>
</html>
However, when I use firefox to identify elements... it gives me a completely different code (which is what I got the buttons and textbox info from):
<html>
<head></head>
<frameset framespacing="0" border="0" frameborder="0" rows="80,*">
<frameset framespacing="0" border="0" frameborder="0" cols="*,22"></frameset>
<frame src="login.html" noresize="" name="loginFrame" scrolling="auto">
#document
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head></head>
<body onload="loadConfiguration();">
<script type="text/javascript" language="javascript"></script>
<form onsubmit="return login();" name="tF" method="post" action="login.html">
<table class="container" style="height: 650px">
<tbody>
<tr>
<td class="container">
<div class="container">
<div class="loginbox">
<!--
Login box HTML code here...
-->
<table class="login">
<tbody>
<tr>
<td id="devname" class="hdr style2" style="color: #ffffff; font-family: Arial, Helvetica, sans-serif;" colspan="2"></td>
</tr>
<tr>
<td class="hdr style2" valign="top"></td>
<td class="maindata">
<input id="password" type="password" onkeypress="capsCheck(event);" size="20" name="password" maxlength="16"></input>
<script type="text/javascript" language="javascript"></script>
<input class="button" type="submit" style="position: relative; top: 2;" value="Login"></input>
<br></br>
<span id="passwd" class="default" style="display: none;"></span>
</td>
</tr>
<tr></tr>
<tr></tr>
</tbody>
</table>
<span id="wrong" class="warning" style="display: none;"></span>
<br></br>
<span id="capsmsg" class="warning" style="display: none;"></span>
<br></br>
It is recommended that you use a minimum of
<br></br>
Microsoft® Internet Explorer 5.5 to view the Inter…
<br></br>
<br></br>
<!--
Login box HTML end...
-->
</div>
</div>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript" language="javascript"></script>
</form>
</body>
</html>
</frame>
</frameset>
<noframes></noframes>
</html>
_IEFormGetObjByName() Returns an object variable, not a collection.
Use _IETagNameAllGetCollection($oForm) to list all of the element inside a object.
Edit:
I have looked closely to the html and I see that the password field has ID and NAME attributes. Use _IEGetObjById to get the object of a password field.
#NoTrayIcon
#include <ie.au3>
$Address = "http://10.255.96.2/index.html"
$pwd="mypassword"
$oIE = _IECreate ($Address)
;_IELoadWait($oIE) Not needed because IECreate does wait for page to load by default.
$oPassword = _IEGetObjById($oIE, "password")
_IEFormElementSetValue ($oPassword, $pwd)
$oForm = _IEGetObByName($oIE, "tF")
_IEFormSubmit($oForm)
Related
My JS code looks like this. But when I open the page it says "Uncaught TypeError: Cannot set property 'innerHTML' of null"
I tried to change the NewItem constructor to a function. But VSC keeps saying I should declare it as a class instead. I converted it in the first place because the constructor wasn't working as a function either.
class NewItem {
constructor(name, date, price) {
this.itemName = name;
this.itemDate = date;
this.itemPrice = price;
}
}
const onListItem = new NewItem("John", "Date", "Price");
document.getElementById("demo").innerHTML = onListItem.itemDate;
HTML looks like this
<!DOCTYPE html>
<html lang= "en">
<head>
<link rel="stylesheet" href="ShopListStyle.css">
<meta name="viewport" content="width=device-width" initial-scale=1.0>
<title>Shopping List</title>
</head>
<body>
<script src="ShopListScript.js"></script>
<div id="container">
<div id="inputbox" class="section">
<form id="labels-form">
<label><h2>Shopping List</h2></label>
<input id="labels-name" class="labels-input" type="text" value="Item Name"></input>
<input id="labels-date" class="labels-input" type="text" value="Date of Purchase"></input>
<input id="labels-price" class="labels-input" type="text" value="Item Price"></input>
<button id="labels-button">Add to List</button>
<p id="demo"></p>
</form>
</div>
<div id="shopListBox" class="section">
<!--Need to add a delete button/ Maybe a quantity button down the road-->
<table id="shopList">
<caption><h2>Spending List</h2></caption>
<thead id="table-header">
<tr>
<th class="table-header" id="table-name">name</th>
<th class="table-header" id="table-date">date</th>
<th class="table-header"id="table-price">price</th>
<th class="table-header" id="table-delete">delete</th>
</tr>
</thead>
<tbody id="table-body">
<tr class="newRow">
<td class="new-item" id="item-name">item</td>
<td class="new-item" id="item-date">item</td>
<td class="new-item" id="item-price">item</td>
<td class="new-item"><button class="item-button">Delete</button></td>
</tr>
</tbody>
<tfoot id="table-footer">
<tr>
<td id="item-price-sum" colspan="4" style="width: 100%" >Sum of Prices</td>
</tr>
</tfoot>
</table>
<!--The sum of all the prices will go somewhere here-->
</div>
</div>
</body>
</html>
Your JavaScript code is trying to access this element with id demo (<p id="demo"></p>):
document.getElementById("demo").innerHTML = onListItem.itemDate;
Your script is added at the opening body tag...
<body>
<script src="ShopListScript.js"></script>
...
...which means the demo element does not exist yet.
Solution: Put your script before the closing body tag:
...
<script src="ShopListScript.js"></script>
</body>
</html>
You can also try to set
<script src="ShopListScript.js" defer="defer"></script>
Because javascript will block the DOM rendering, so we should put in the end of
like Peter Krebs's answer:
...
<script src="ShopListScript.js"></script>
</body>
I have the following index.html page, I inserted a div of class "topnav" (see a section with additional hard returns).
Now I need the same code (div of class "topnav") in all other HTML pages in the directory. This could be a few hundreds of files!
I was thinking: "can somebody help me with the creation of a script?" or by pushing a javascript file that can transform all HTML pages in the folder? All the pages have the same header. So we could say: after the first , add a new and section with the home/search
function relPathToAbs(sRelPath) {
var nUpLn, sDir = "",
sPath = location.pathname.replace(/[^\/]*$/, sRelPath.replace(/(\/|^)(?:\.?\/+)+/g, "$1"));
for (var nEnd, nStart = 0; nEnd = sPath.indexOf("/../", nStart), nEnd > -1; nStart = nEnd + nUpLn) {
nUpLn = /^\/(?:\.\.\/)*/.exec(sPath.slice(nEnd))[0].length;
sDir = (sDir + sPath.substring(nStart, nEnd)).replace(new RegExp("(?:\\\/+[^\\\/]*){0," + ((nUpLn - 1) / 3) + "}$"), "/");
}
return sDir + sPath.substr(nStart);
}
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>6129103883 - Schema ST4 styles -- Reference view - do not translate this file. Aperçu de référence - ne pas traduire ce fichier. Referenzansicht - diese Datei nicht übersetzen.</title>
<meta http-equiv="Content-Script-Type" content="text/javascript"
/>
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="generator" content="SCHEMA ST4" />
<script language="JavaScript" src="Scripts/Common.Core.js" type="text/javascript" charset="UTF-8">
</script>
<script language="JavaScript" src="Scripts/Common.Language.js" type="text/javascript" charset="UTF-8">
</script>
<script language="JavaScript" src="Scripts/Production.js" type="text/javascript" charset="UTF-8">
</script>
<link rel="stylesheet" href="layout.css" type="text/css" />
<link rel="stylesheet" href="CSS/Common.Reset.css" type="text/css" />
<link rel="stylesheet" href="CSS/Core.Production.css" type="text/css" />
<link rel="stylesheet" href="CSS/HTML.css" type="text/css" />
</head>
<body>
<div class="page">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="metatable">
<tr>
<td class="project">Schema ST4 styles -- Reference view - do not translate this file. Aperçu de référence - ne pas traduire ce fichier. Referenzansicht - diese Datei nicht übersetzen.</td>
</tr>
<td>
<tr>
<div class="topnav">
<a class="active" href="#home">Home</a>
<input type="text" placeholder="Search..">
</div>
</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" class="contentLayout">
<tr>
<td class="contentLayoutOne">
<div class="navigation tripletNavigation">
<div class="tripletHead tripletHeadInfoType">Example of Heading 0 (metadata – Installer or User)</div>
<div class="tripletHead tripletHeadInfoType">Example of Heading 1 (metadata – TitleAcrossAllColumns)</div>
<div class="tripletHead tripletHeadInfoType">Example of Heading 1 (metadata – TitleAsSectionTitle)</div>
<div class="tripletHead tripletHeadInfoType">Example of Heading 1</div>
<div class="tripletHead tripletHeadInfoType">New Node</div>
<div class="tripletHead tripletHeadInfoType">New Node</div>
<div class="tripletHead tripletHeadInfoType">Button yes/no</div>
<div class="tripletHead tripletHeadInfoType">Button history yes</div>
<div class="tripletHead tripletHeadInfoType">Button history no</div>
<div class="tripletHead tripletHeadInfoType">Button history</div>
<div class="tripletHead tripletHeadInfoType">Topic that contains fragment to link to</div>
<div class="tripletHead tripletHeadInfoType">Topic with links</div>
</div>
</td>
<td class="contentLayoutTwo"><img src="" /></td>
<td class="contentLayoutThree">
<div class="content">
<div class="titlePageContent"> </div>
</div>
</td>
</tr>
</table>
</div>
</body>
</html>
We inserted of course just the bar at this moment, so we still need a search javascript too to add in the folder structure/HTML pages. Any recommendations?
If you use the find and replace functionality in something like Visual Studio Code you can just replace this entire header with the updated one.
I'm using math formula in ckeditor, when I insert new content by textarea, it can read math formula, but if I edit this content, it seem can not read and display text formula as before..
this is my source:
<head>
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['\\(','\\)']]}});</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script src="https://cdn.ckeditor.com/4.7.3/standard/ckeditor.js"> </script>
</head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<span >Question Code : <%=id_q%> - <%=valid_types%> (Number presented : <%=make_cnt%>)</span>
<table border="0">
<tr>
<td width="640" height="650">
<textarea name="ir1" id="ir1" rows="1" cols="10" style="width:580px; height:600px; min-width:400px; min-height:50px; display:none;"></textarea>
<script>
var ir1 = CKEDITOR.replace('ir1', {
extraPlugins: 'mathjax,video,font,justify,preview,colorbutton,panelbutton',
mathJaxLib: 'https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-AMS_HTML'
});
CKFinder.setupCKEditor(ir1, 'libraries/ckfinder/');
</script>
</td>
</tr>
</table>
</body>
This is result when I cliked edit button for content:
How to display correct mathjax in ckeditor when edit content? thanks
You could try to move the MathJax-script to the bottom of your head tag like this:
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script src="https://cdn.ckeditor.com/4.7.3/standard/ckeditor.js"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['\\(','\\)']]}});</script>
</head>
To ensure the code has access to the MathJax namespace.
I am trying to get my variable I have saved to display on a table I have created on another page. I get the information from the user from a form, and have a button that is clicked and fires off to save the values into variables. My problem is that I can't change the inner html on the other page with the variable I have saved. I am using 1 js file and 2 html files. I can only use js/jquery, html, and css. here is my code:
loanpage.html
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Super Awesome Loan Guys</title>
<link rel="stylesheet" type="text/css" href="loanpage.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="loanpage.js"></script>
</head>
<body>
<div class="bg" id="text-center">
<div class="companytitle"><span class="dollar">$</span>uper Awe<span class="dollar">$</span>ome Loan Guy<span class="dollar">$</span></div>
<div>
<form action="infopage.html">
<h4>Loan Amount:</h4>
<input type="text" id="loanamount" name="loanamount"><br>
<input type="radio" id="12month" name="time">12 Months
<input type="radio" id="18month" name="time">18 Months
<input type="radio" id="24month" name="time">24 Months
<h4>Name:</h4><input id="namefield" type="text" name="firstlastname">
<h4>Phone:</h4><input id="phonefield" type="text" name="phonennumber">
<h4>Email:</h4><input id="emailfield" type="text" name="email">
<h4>Zip Code:</h4><input id="zipfield" type="text" name="zipcode"><br>
</form>
<button type="button">Submit</button>
</div>
</div>
</body>
</html>
infopage.html
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Super Awesome Loan Guys Loan Information</title>
<link rel="stylesheet" type="text/css" href="loanpage.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="loanpage.js"></script>
</head>
<body>
<div class="bg" id="text-center">
<h1>Here is the info you submitted!</h1>
<table>
<tr>
<th>Name</th>
<th>Phone Number</th>
<th>Email Address</th>
<th>Zip Code</th>
<th>Loan Amount</th>
<th>Loan Duration</th>
<th>Interest</th>
</tr>
<tr>
<td id="displayName">1</td>
<td id="displayPhone">1</td>
<td id="displayEmail">1</td>
<td id="displayZip">1</td>
<td id="displayAmount">1</td>
<td id="displayDuration">1</td>
<td id="displayInterest">1</td>
</tr>
</table>
</div>
</body>
</html>
loanpage.js
//js code
var name = "";
var phone="";
var email="";
var zip="";
var loan=0;
var loanrate=12.0;
var loanlen=0;
//Jquery code
$(document).ready(function (){
$("#submitbutton").click(function(){
loan = parseFloat($("#loanamount").val());
if ($("#12month").is(':checked')){
loanlen = 12;
}
else if ($("#18month").is(':checked')){
loanlen = 18;
}
else if ($("#24month").is(':checked')){
loanlen = 24;
}
name = $("#namefield").val();
phone = $("#phonefield").val();
email = $("#emailfield").val();
zip = $("#zipfield").val();
document.getElementById("displayName").innerHTML(name);
document.getElementById("displayPhone").innerHTML(phone);
document.getElementById("displayEmail").innerHTML(email);
document.getElementById("displayZip").innerHTML(zip);
document.getElementById("displayAmount").innerHTML(loan);
document.getElementById("displayDuration").innerHTML(loanlen);
document.getElementById("displayInterest").innerHTML(loanrate);
});
});
Local Storage is your best bet.
// Save data to the current local store
localStorage.setItem("username", "John");
// Access some stored data
alert( "username = " + localStorage.getItem("username"));
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
I am working on a history search function.
I have managed to get a working code to save the value from the textbox but I do not know how to load them into a listbox.
I want a listbox with clickable items so that I can click on a previous search value and load that value as I do from the textbox.
Here is my code:
<!doctype html>
<html lang="en">
<head>
<title>Test</title>
<meta charset="utf-8>
<link rel="stylesheet" type="text/css" href="test.css">
<script src="jquery.js"></script>
<script src="j.js"></script>
</head>
<body>
<center>
<table>
<tr>
<td style="text-align: center">
<font size="22">Sök order</font>
</td>
</tr>
<tr>
<td>
<form action="test.php" method="post">
<input style="font-size: 44pt; text-align: center" size="9" type="text" name="txtSearch" id="txtSearch"/>
<input type="submit" id="submit" value="submit">
</form>
</td>
</tr>
</table>
</center>
</body>
</html>
And the j.js that handles the local storage function.
$(function () {
$("#submit").click(function () {
var txtSearch = $("#txtSearch").val();
localStorage.setItem('searchvalue',txtSearch);
});
});
And last my test.php that handles the post search request
<?php
$txtSearch = $_REQUEST['txtSearch'];
header('Location: '.'https://mywebsite.com/se/editor/order_info.php?webshop=23946&ordernr='.$txtSearch);
?>
How can I achieve this?
Thank you.
by js, you can
window.location = "https://mywebsite.com/se/editor/order_info.php?webshop=23946&ordernr="+localStorage.getItem('searchvalue');
to save in listbox or any other
document.getElementById("id").value=localStorage.getItem('searchvalue');
to save in array
var a = [];
a[0]=localStorage.getItem('searchvalue');