function msg ($msg) {
echo "<script type='text/javascript'>alert('$msg');</script>";
}
if (count($_POST)) {
msg('TEST!!!!!');
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My website</title>
<link rel="stylesheet" type="text/css" href="/assets/css/main.css" />
</head>
<body>
<div id="content">
<form action="/user/register" method="post">
<table cellspacing="2" cellpadding="0">
<tr>
<td>Username:</td>
<td><input name="username" maxlength="25" size="25" type="text" />
</td>
</tr>
<tr>
<td>E-mail:</td>
<td><input name="email" maxlength="255" size="25" type="text" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" maxlength="255" size="25" type="password" /></td>
</tr>
<tr>
<td>Confirm password:</td>
<td><input name="password2" maxlength="255" size="25" type="password" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Register" /></td>
</tr>
</table></div>
</body>
</html>
When I post it doews show the alert but on a blank page. The form vanish when i press submit. How can I do so it still shows the the html?
The message pops up but on a blank page. I want it to still show the page your on
First, You need to put the script in the tags, instead of above the DOCTYPE. Try this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My website</title>
<link rel="stylesheet" type="text/css" href="/assets/css/main.css" />
<?php
if (count($_POST)) {
msg('TEST!!!!!');
}
?>
</head>
After that, there might be more problems.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My website</title>
<link rel="stylesheet" type="text/css" href="/assets/css/main.css" />
<script type='text/javascript'>
(function(){
var countPost = <?php echo ((count($_POST)>0)?count($_POST):0); ?>;
if (countPost>0)
alert('msg test');
})()
</script>
</head>
Related
I have a jsp page,that containing table with few row and few column. In each row two fields are changeable (drop down, textarea).and one cell have save button.
I want to hit the spring controller via save button with all the row parameters.
in below code save and delete are two button, both will hit the spring controller with row parameters.
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%#page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="shortcut icon" href="/favi.ico">
<link href="/common.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<form:form method="POST" action="/saveCCVTData/" modelAttribute="cCVTeamDataResultEntity">
<table id="customers">
<tr>
<th>Sr. No</th>
<th>ServiceOwner</th>
<th>LeadName</th>
<th>Service</th>
<th>Month</th>
<th>TeamSize</th>
<th>Remark</th>
<th>Updated Date</th>
<th>Save/Update | Delete</th>
</tr>
<c:forEach items="${content}" var="e">
<tr>
<td></td>
<td>${e.serviceOwner}</td>
<td>${e.leadName}</td>
<td>${e.services}</td>
<td>
<select name="monthList" id="monthList">
<c:forEach items="${monthList}" var="monthList" varStatus="loop">
<option value="${loop.index}">${monthList}</option>
</c:forEach>
</select>
</td>
<td>
<textarea id="teamSize" name="teamSize" rows="1" cols="3">${e.teamSize}</textarea>
</td>
<td>
<textarea id="remark" name="remark" rows="4" cols="25">${e.remark}</textarea>
</td>
<td>
<input type="date" id="date" name="date" value=${e.date}>
</td>
<td>
<button id="save" type="button" class="btn btn-info btn-sm" onclick="window.location='/saveCCVTData/?serviceOwner=${e.serviceOwner}&leadName=${e.leadName}&services=${e.services}&teamSize=${e.teamSize}&remark="document.getElementById("remark").value"&date=${e.date}';">Save/Update</button>
<button id="delete" type="button" class="btn btn-warning btn-sm" onclick="window.location='/deleteCodeCoverage/';">Delete</button>
</tr>
</c:forEach>
</table>
</form:form>
</body>
</html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>TL-WR841N</title>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="wed, 26 Feb 1997 08:21:57 GMT">
<link href="/dynaform/css_main.css" rel="stylesheet" type="text/css">
<script language="javascript" src="/dynaform/common.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript"><!--
if(window.parent == window){window.location.href="http://192.168.1.1";}
function Click(){ return false;}
document.oncontextmenu=Click;
//--></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript"><!--//
function doSubmit()
{
if(confirm(js_to_reboot="Are you sure to reboot this device?"))
{
location.href = "/userRpm/SysRebootRpm.htm";
return true;
}
else
{
return false;
}
}
//--></script>
</head>
<body onload="setTagStr(document,'ntw_sys_reboot');LoadHelp('SysRebootHelpRpm.htm'); resize(this);" onresize="resize(this);" marginwidth="0" marginheight="0">
<center>
<form action="SysRebootRpm.htm" enctype="multipart/form-data" method="get" onsubmit="return doSubmit();">
<table id="autoWidth" style="width: 950px;">
<tbody>
<tr>
<td class="h1" id="t_title">Reboot</td>
</tr>
<tr>
<td class="blue"></td>
</tr>
<tr>
<td class="info" id="t_notice">Click this button to reboot this device.</td>
</tr>
<tr>
<td class="mbtn"><input name="Reboot" type="submit" class="buttonBig" value="Reboot" id="reboot"></td>
</tr>
<tr>
<td class="blue"></td>
</tr>
</tbody>
</table>
</form>
</center>
<meta http-equiv="pragma" content="no-cache">
</body></html>
Above is from the modem page.
Is there is a way to extract the javascript to make reboot modem as easy as one-click.
Does anyone have any idea?
I have a page in my PhoneGap webapp (file:///mypath/), that opens a webpage (http://www.example.com/) in my server. In this webpage I need to return after I do all my stuff in my webapp.
This is my webpage source:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="HandheldFriendly" content="True">
<meta http-equiv="cleartype" content="on">
<link rel="stylesheet" type="text/css" href="css/stile.css">
<meta name="viewport" content="width=320, initial-scale=0.7, user-scalable=no">
<script src="JS/jquery-1.11.1.js.js"></script> <!--PER EVENTI-->
<script src="JS/func.js"></script> <!--PER EVENTI-->
<title>BParty</title>
</head>
<body style="background-color:#e20a7e; overflow:none;">
<img src="IMG/CIAMBELLA_03.png" class="icons5" style="display:block; margin: 0 auto;">
<br>
<br>
<div align="center" style="color:#FFF;">
<table align="center" width="100%">
<tr>
<font style="font-size:5em;">OOPS!</font><br>
</tr>
<tr>
<font style="font-size:2.5em;">Sembra che tu non sia connesso</font><br>
</tr>
<tr>
<font style="font-size:1.5em;">A breve sarai reindirizzato</font>
</tr>
<br>
<tr>
<font style="font-size:1em;">Se non vuoi aspettare clicca
QUI</font>
</tr>
</table>
</div>
<?
header( "refresh:5;url=$location" ); ?>
</body>
</html>
This is my localpage:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento senza titolo</title>
<script type="text/javascript">
var ourLocation = document.URL;
</script>
</head>
<body>
<script>
var goto = "<a href='http://www.bestparty.altervista.org/MIRKO/pag2.php?location=" + ourLocation + "'>dicjdb</a>";
document.write(goto);
</script>
</body>
</html>
EDIT
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="HandheldFriendly" content="True">
<meta http-equiv="cleartype" content="on">
<link rel="stylesheet" type="text/css" href="css/stile.css">
<meta name="viewport" content="width=320, initial-scale=0.7, user-scalable=no">
<script src="JS/jquery-1.11.1.js.js"></script> <!--PER EVENTI-->
<script src="JS/func.js"></script> <!--PER EVENTI-->
<title>BParty</title>
</head>
<body style="background-color:#e20a7e; overflow:none;">
<div id="navigation" style="overflow:none;">
<table width="100%">
<tr valign="bottom">
<td valign="middle" width="25%" align="center">
</td>
<td valign="bottom" width="50%" align="center">
<img src="IMG/LOGO-WHITE.png" class="logonbar" alt="DONUT"/>
</td>
<td width="25%" align="center" valign="middle">
</td>
</tr>
</table>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<img src="IMG/CIAMBELLA_03.png" class="icons5" style="display:block; margin: 0 auto;">
<br>
<br>
<div align="center" style="color:#FFF;">
<table align="center" width="100%">
<tr>
<font style="font-size:5em;">OOPS!</font><br>
</tr>
<tr>
<font style="font-size:2.5em;">Sembra che tu non sia connesso</font><br>
</tr>
<tr>
<font style="font-size:1.5em;">A breve sarai reindirizzato</font>
</tr>
<br>
<tr>
<font style="font-size:1em;">Se non vuoi aspettare clicca
QUI</font>
</tr>
</table>
</div>
<script>
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
</script>
<script>
variable = getUrlVars()["location"];
alert(variable);
//window.location.href = variable;
</script>
</body>
</html>
I added the js script to return at the local page on my app but it doesn't work, it stays on my php page on my server, same result by clicking the a href that contains the php
I agree with Shaun Loftin.
Anyway, you can embed a local webpage using a simple IFRAME.
<iframe src="http://localhost/local_webpage.php"></iframe>
I am having a List in html page, which should get Updated on the Click of Button.
I am also having a textfield and Button. value entered in textfield should display in listbox on click of Button.
This is my Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script type="text/javascript">
function addsoap(form1)
{
if(document.form1.datafile.value=="")
{
alert("Select a File First");
}
else
{
var soap=document.getElementById("right1");
var newsoap=document.createElement('option');
newsoap.text=document.form1.datafile.value;
newsoap.value=document.form1.datafile.value;
soap.add(newsoap);
}
}
</script>
</head>
<body>
<table align='center'>
<form name="form1">
<tr>
<td>Please specify a file, or a set of files:<br>
<input type="file" name="datafile" size="40">
</td>
</tr>
<tr>
<td><input type=button value="ADD" onclick="addsoap(form1)" ></td>
</tr>
<tr>
<td align="right"><select id="right1" size="10" multiple>
<option>AAAAAAAAAAAAAAAAAAAAAAAAA</option>
</select></td>
</tr>
</form>
</table>
</body>
</html>
instead of .add method use .appendChild Method
Here's my full, latest code that doesn't work. Here's the main window HTML
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Website</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
</head>
<body background="core_rec/web_res/cf2.jpg">
<center>
<table width="720" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="180"><img src="core_rec/logos/metaltop.png" /></td>
<td colspan="3"><img src="core_rec/web_res/title.png" align="bottom"/></td>
</tr>
<tr>
<td width="180"><img src="core_rec/logos/metalbottom.png" /></td>
<td width="70"><center><font id="menutext">Menu</font></center></td>
<td width="100"><center><font id="menutext">Info</font></center></td>
<td width="200"><center><font id="menutext">Products/Services</font></center></td>
<td width="170"><center><font id="menutext">Contact</font></center></td>
</tr>
</table>
<br /><br />
<table height="80%" width="720">
<tr>
<td width="140"><iframe src="iframes/menus/main.html" width="140" id="sidebar"></iframe></td>
<td width="540"><iframe src="iframes/bodies/main/main.html" width="540" name="bodyframe" id="bodyframe"></iframe></td>
</tr>
</table>
</center>
</html>
Here's the menus/main.html. It contains the button.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>iFrame Main</title>
<link rel="stylesheet" type="text/css" href="../../css/main.css" />
</script>
</head>
<body bgcolor="#000000">
<center>
<font id="sidebartext">
Main<br /><br />
Other Feeds<br /><br />
<button onclick="parent.document.getElementById('bodyframe').src='../bodies/main/othersites.html'">Other Sites</button><br /><br />
</font>
</center>
</body>
</html>
Whenever I push the button on the menu frame, the body frame doesn't change.
Make sure to run this on a simple server and test. Many browsers have restrictions when it comes to iframes.
Many files don't work properly if using file:// protocol, which will be used if you directly open the html file (i.e.: Not through a server).
You misspelled getElementById: last letter d should not be uppercase.
Instead of window.document.getElementById you could write document.getElementById, because window is the global object in browser javascript (at least, global per window/(i)frame)
http://jsfiddle.net/kNrVL/