<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<Script language = JavaScript>
function addOptionList(selectbox,text,value )
{
var optn = document.createElement('OPTION');
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
function removeOptionList(listbox,i){
listbox.remove(i);
}
function addOption_list(fromvar,tovar){
for(i=fromvar.options.length-1;i>=0;i--) {
var userlist=fromvar;
if(fromvar[i].selected){
addOptionList(tovar, fromvar[i].value, fromvar[i].value);
removeOptionList(userlist,i);
}
}
}
</Script>
<table align='center'>
<tr>
<td ><select multiple name='userlist' id='userlist' >
<option value='aaa'>aaa</option>
<option value='bbb'>bbb</option>
</select></td>
<td align='center' valign='middle'>
<input value='-->'
onClick='addOption_list(userlist,pouser);' type='button'>
<br><input value='<--'
onClick='addOption_list(pouser,userlist);' type='button'></td>
<td><select multiple name='pouser' id='pouser'>
<option id='test' value='ccc'>ccc</option>
</select></td>
</tr>
</table>
</body>
</HTML>
I am using the code above to select a name from left box and move it to the right box. The code is working in IE with/without DOCTYPE. But when I use DOCTYPE, it stops working in Firfox. I have spent a lot of time on it, but still couldn't figure out the problem. Also, I am a novice in Javascript, so please explain me the problem with code below (when I am using DOCTYPE). Thanks in advance for your help!!
You're relying on elements with ids showing up as global properties on the window (e.g. userlist). Firefox only does that in quirks mode, which is why the doctype matters.
Your markup does not match the DOCTYPE. I.e. you are not using valid XHTML 1.0 markup.
Paste you code into the xhtml validator and it will show you what's wrong.
Related
In Selenium IDE I'm trying to invoke some key shortcuts in browser. For example let's say I want to reload http://www.google.com page with:
Command: sendKeys
Target: //body
Value: ${KEY_F5}
Script passes, but is not working. Switching to any frame first also not working.
In webdriver I'm successfully using:
driver.findElement(By.xpath("//body")).sendKeys(Keys.F12);
I'm aware of refresh command in IDE, but it won't solve my problem because what I really need to do is send different F1-12 keys...
Am I missing something?
I've also tried click first at body element but I'm not able to make it work and send any F1-12 keys to window/page and not to an element.
Run the following code and you will see how your sendKey KEY_F5 is working. when script reaches sendKeys, the searchbar is being triggered It is my guess that body is being refreshed not the whole document. Not sure..though
<?xml version="1.0" encoding="UTF-8"?>
<!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" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.google.com/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/?gws_rd=ssl</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=lst-ib</td>
<td>dsad</td>
</tr>
<tr>
<td>click</td>
<td>name=btnG</td>
<td></td>
</tr>
<tr>
<td>sendKeys</td>
<td>//*</td>
<td>${KEYS_F5}</td>
</tr>
</tbody></table>
</body>
</html>
I'm have made a upload page in classic asp and it works fine, as long as the filenames are not in utf-8 characters. I have added charset til the page and the form accepts utf-8 characters but my files are saved as Доклад Региона.pdf bug should be Доклад Региона.pdf
I don't know if there is anything more I can do or it is the "Pure-ASP file upload" that does not support utf-8 characters.
Does anyone how to fix it?
My asp page looks like this
<%
Response.CodePage = 65001
Response.CharSet = "utf-8"
'Create upload form
'Using Huge-ASP file upload
'Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'Using Pure-ASP file upload
Dim Form: Set Form = New ASPForm %><!--#INCLUDE FILE="upload2.asp"--><%
dim File
DestinationPath = Server.mapPath("Files")
If Form.State = 0 Then 'Completted
For Each File In Form.Files.Items
If Len(File.FileName) > 0 Then
Form.Files.Save DestinationPath
End If
Next
End If
%>
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Project Site</title>
<link id="ss__cs" rel="stylesheet" href="CSS/stylesheet.css" type="text/css"/>
</head>
<body style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; padding: 0;" >
<form method="POST" id="myform" ENCTYPE="multipart/form-data" acceptcharset="UTF-8">
<table>
<tr>
<td>File</td>
<td><input type="file" id="File1" name="File1" class="defaultfont"></td>
</tr>
<tr height="10">
</tr>
<tr>
<td></td>
<td><input Value="Cancel" Type="button" class="defaultfont" onclick="window.close()"> <input Value="Upload file" Type="submit" class="defaultfont" ></td>
</tr>
</table>
</Form>
</body>
</html>
Try adding
If Form.State = 0 Then 'Completted
'Add this line to set the character set based on the response.
Form.CharSet = Response.CharSet
For more information see Upload - use unicode (utf-8) character set for request/response data .
I'm looking to parse an xhtml document with Microsoft.XMLHTTP with XPATH in VBScript. I have the following xhtml document structure. How would I get an array of the urls?
<!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=iso-8859-1" />
<title>Local index</title>
</head>
<body>
<table>
<tr>
<td>
url1<br/>
url2<br/>
url3
</td><td>
url1-1<br/>
url2-1<br/>
url3-1
</td>
</tr>
</table>
</body>
</html>
Are you sure you need to use the antiquated program id Microsoft.XMLHTTP? These days both MSXML 3 as well as MSXML 6 are part of the OS respectively supported service packs with anything since Windows XP.
As for using XPath and MSXML 3, here is an example:
Dim doc
Set doc = CreateObject("Msxml2.DOMDocument.3.0")
doc.validateOnParse = False
doc.resolveExternals = False
If doc.load("file.xml") Then
doc.setProperty "SelectionLanguage", "XPath"
doc.setProperty "SelectionNamespaces", "xmlns:xhtml='http://www.w3.org/1999/xhtml'"
For Each link In doc.selectNodes("//xhtml:a")
WScript.Echo(link.getAttribute("href") & ": " & link.text)
Next
Else
WScript.Echo(doc.parseError.reason)
End If
This should be an easy fix for the right guru! Everything is working for me except that I can't get this form to submit without clicking the submit button. The data values are all valid. The action page, ...gdform.php, uses $_post to get the "redirect" value from the form and then uses php to do a header Location change. That works fine if I execute the form with the submit button. I just need it to happen without any click...
Take a look, please!
<?php session_start();
require_once('Connect.php') ;
?>
<!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>Nitrofill Document</title>
<?php
//error_reporting(E_ALL);
$sn=$_GET['num'];
echo $sn;
mysql_connect($hostname,$username, $password) OR die('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);
$selectSQL = "select * from `Presentations` where `serialnum` ='" . $sn ."'" ;
$result = mysql_query($selectSQL) or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_BOTH);
$thedoc = urldecode($row['docurl']);
$therecip=urldecode($row['recipient']);
$thetracker=urldecode($row['tracker']);
$lastacc=urldecode($row['last_accessed']);
?>
</head>
<body>
<form id="notice" action="http://m3sglobal.com/gdform.php" method="post">
<input name="subject" value="<?php echo $therecip . " has viewed the document you sent them.";?> " />
<input type="hidden" name="redirect" value="<?php echo $thedoc ; ?>"/>
<label>Email:</label><input type="text" name="email" value="<?php echo $thetracker ; ?>"/>
<label>Comments:</label><textarea name="comments" cols="40" rows="5">
Document Viewed:<?php echo $thedoc ; ?>
When Accessed:<?php echo $lastacc ; ?>
</textarea>
<input type="submit" name="submit"/>
</form>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
myfunc
});
function myfunc () {
var frm = document.getElementById("notice");
frm.submit();
}
</script>
I might be wrong but shouldn't it be: (corrected typos)
$(document).ready(function(){
myfunc(); <--// with ();
});
function myfunc() { <--// without space
var frm = document.getElementById("notice");
frm.submit();
}
or better yet:
$(document).ready(function(){
$("form#notice").submit();
});
EDIT:
Prowla is right, you also didn't declare the jQuery library. Good catch Prowla, I missed that, just saw the typos.
EDIT #2:
Your code is pretty messy there, and you have that PHP generated string in the <head>. Also your submit had no value, you used name. I cleaned it up, here is working code (for me at least):
<!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>Nitrofill Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("form#notice").submit();
});
</script>
</head>
<body>
<!--// ALL THE PHP SHOULD GO HERE TO MAKE THE URL BELOW //-->
qyO452ZKphttps://docs.google.com/presentation/pub?id=1chxqg-qjrfEvAR9_Jia7lt4ps2_Q7IfTiI41bQE7Q_4&start=true&loop=false&delayms=3000<br/>greg.mcgee#gmail.com<br/>greg.mcgee#advetel.com<br/>Thu, 23 Feb 2012 19:42:11 MST<br/>
<!--// END PHP //-->
<form id="notice" action="http://m3sglobal.com/gdform.php" method="post">
<input name="subject" value="greg.mcgee#gmail.com has viewed the document you sent them. " />
<input type="hidden" name="redirect" value="https://docs.google.com/presentation/pub?id=1chxqg-qjrfEvAR9_Jia7lt4ps2_Q7IfTiI41bQE7Q_4&start=true&loop=false&delayms=3000"/>
<label>Email:</label><input type="text" name="email" value="greg.mcgee#advetel.com"/>
<label>Comments:</label><textarea name="comments" cols="40" rows="5">
Document Viewed:https://docs.google.com/presentation/pub?id=1chxqg-qjrfEvAR9_Jia7lt4ps2_Q7IfTiI41bQE7Q_4&start=true&loop=false&delayms=3000
When Accessed:Thu, 23 Feb 2012 19:42:11 MST
</textarea>
<input type="submit" value="submit"/>
</form>
</body>
</html>
You might want to consider using firebug to help you troubleshoot your pages. Its how I figured this out. Also remember Prowla's advice, and protect your SQL.
Using jQuery: (Remember to put the jquery script in your <head> tags).
<head>
...
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
...
<head>
...
// submit form with id notice
$(document).ready(function(){
$('#notice').submit();
});
Also your SQL is subject to injection. Please look into using prepared statements.
Sample in PHP:
$mysqli = new mysqli('localhost', 'user', 'password', 'db');
$stmt = $mysqli->prepare('select * from `Presentations` where `serialnum` =?');
$stmt->bind_param('i',$sn);
$stmt->execute();
....
I'm new on Grails and I have some troubles with Ajax (so I could have missed something). On my main gsp I want a select box, that, when I click on its options, makes appear another field on the same page to select other things. As the content in the second part is dynamic, I need somme Ajax. Anyway I haven't succeed yet. Here is my code :
main.gsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="layout" content="main" />
<title>Sample title</title>
<g:javascript library="jquery"/>
</head>
<body>
<h1>Selection de l'email</h1>
<div class="dialog">
<g:select name="selectTemplate"
from="${templateCategories}"
value="category"
noSelection="['':'--- choisissez un modèle ---']"
onchange="${remoteFunction(
controller:"email"
action:"printTestTemplate"
update:"listTemplates"
params:'\'category=\'+this.value'
)}"
/>
<div id="listTemplates">RRR</div>
</div>
</body>
</html>
EmailController
def printTestTemplate = {
println params.category //doesn't print anything
println "YEAAAAAAAAAH" //the same
render(view:"formSelectTemplate", model:[templates:EmailTemplate.findByCategory(params.templateCategory)])
}
formSelectTemplate.gsp
<h1>YOUHOUUU !</h1>
I've both tried to call a view or template (by renaming the gsp of course), but nothing worked. Nevertheless I don't understand, I followed the official doc. Notice that the HTML result creates no event on the select box, and that Firebug tells me there is no 404. So I must have missed something in the creation of the box.
select result in HTML :
<select id="selectTemplate" name="selectTemplate">
<option value="Refus">Refus</option>
<option value="Informations complémentaires">Informations complémentaires</option>
</select>
Did you forget comas between the arguments of your remoteFunction call ? like this:
onchange="${remoteFunction(controller:"email",
action:"printTestTemplate",
update:"listTemplates",
params:'\'category=\'+this.value' )}"