Sorry, I speak English very badly.
I have one form that, when called from various buttons, should hide some fields.
Here are the buttons:
<a data-target="#call">Button 1</a>
<a data-target="#call">Button 2</a>
Here is the form:
<div id="call">
<form>
<div class="pole1">Field 1</div>
<div class="pole2">Field 2</div>
</form>
</div>
A form can have only one ID, in my case it is a "call".
How to make that when you click on the "Button 1" only displayed "Field 1"?
How to make that when you click on the "Button 2" only displayed "Field 2"?
Try with this.
<!DOCTYPE html>
<html>
<body>
<a href="#" onclick='myFunction1()'>Button 1</a>
Button 2
<div id="call">
<form>
<div class="pole1" id="Field1Id">Field 1</div>
<div class="pole2" id="Field2Id">Field 2</div>
</form>
</div>
<p id="demo"></p>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script>
function myFunction1() {
$("#Field1Id").show();
$("#Field2Id").hide();
}
function myFunction2() {
$("#Field1Id").hide();
$("#Field2Id").show();
}
</script>
</body>
</html>
Please try this
<a data-target="#call" onclick="show('id1');">Button 1</a>
<a data-target="#call" onclick="show('id2');">Button 2</a>
Here is the form:
<div id="call">
<form>
<div class="pole1" id="id1" style="display:none">Field 1</div>
<div class="pole2" id="id2" style="display:none">Field 2</div>
</form>
</div>
javascript code :
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
function show(elementId)
{
document.getElementById("id1").style.display="none";
document.getElementById("id2").style.display="none";
document.getElementById(elementId).style.display="block";
}
</script>
scrapy shell http://www.zvon.org/comp/r/tut-XPath_1.html
response.css("div.description")
response.xpath('//div[#class="description"]')
I am a newbie of scrapy, when I want to write a spider by myself, I tried to crawl the text from http://www.zvon.org/comp/r/tut-XPath_1.html, includeing the description text and the right bar text, in order to make the next page url, I have spend 5 hours,but I am failed to write the right CSS or Xpath,such as the xpath of
<div class="right_menu_body_item">List of XPaths</div>
and
<div class="description">XPath is described in XPath 1.0 standard.
anyone can help? thanks!
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-15189975-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
</script>
<div id="page">
<div id="top"><h1 class="top">XPath 1.0 Tutorial</h1>
</div>
<div id="right" style="width: 230px;"><div style="width:234px; margin-top:10px; height:60px;background:url(http://www.highposition.net/embedded/img/234x60-hpbg.png);color#fff" id="hpban">
<div style="padding:9px;padding-left:78px;font-family:arial;color:#fff;font-size:11px;">For a flurry of SEO tips, tricks, articles and advice - visit HP Group.</div></div>
<div id="right_menu_header">
<div class="right_menu_header_item right_menu_header_item_selected">
Pages
<span id="header_count_Pages" style="font-style:italic; font-weight:normal">(23)</span></div>
<div class="right_menu_header_item">
Keywords
<span id="header_count_Keywords" style="font-style:italic; font-weight:normal">(34)</span></div>
<div id="filter_div">filter: <input name="right_menu_filter" id="right_menu_filter"></div>
<div class="filter_div_comment"><input name="regexpEnabled" id="regexpEnabled" type="checkbox">enable regexp (?)</div>
</div>
<div id="right_menu_body"><div class="pn_right_menu_body_ttt"><span class="right_menu_body_first_passive">First</span> - <span class="right_menu_body_prev_passive">Prev</span> - <span class="right_menu_body_next">Next</span></div>
<div id="right_menu_body_head">
1
-
20
<span style="color:red; font-weight:bold">filter: off</span> (23)
</div>
**<div class="right_menu_body_item">List of XPaths</div>**
<div class="right_menu_body_item">XPath as filesystem addressing</div>
<div class="right_menu_body_item">Start with //</div>
<div class="right_menu_body_item">All elements: *</div>
<div class="right_menu_body_item">Further conditions inside []</div>
<div class="right_menu_body_item">Attributes</div>
<div class="right_menu_body_item">Attribute values</div>
<div class="right_menu_body_item">Nodes counting</div>
<div class="right_menu_body_item">Playing with names of selected elements</div>
<div class="right_menu_body_item">Length of string</div>
<div class="right_menu_body_item">Combining XPaths with |</div>
<div class="right_menu_body_item">Child axis</div>
<div class="right_menu_body_item">Descendant axis</div>
<div class="right_menu_body_item">Parent axis</div>
<div class="right_menu_body_item">Ancestor axis</div>
<div class="right_menu_body_item">Following-sibling axis</div>
<div class="right_menu_body_item">Preceding-sibling axis</div>
<div class="right_menu_body_item">Following axis</div>
<div class="right_menu_body_item">Preceding axis</div>
<div class="right_menu_body_item">Descendant-or-self axis</div>
<div class="pn_right_menu_body_bbb"><span class="right_menu_body_first_passive">First</span> - <span class="right_menu_body_prev_passive">Prev</span> - <span class="right_menu_body_next">Next</span></div></div></div>
<div id="left">
<div id="search_div"><div><input id="search_input" name="search_input" value="...loading..."> <img id="plus_google" src="http://gmodules.com/ig/images/plus_google.gif" style="margin:2px" alt="Add to Google" border="0"><div id="search_input_text"></div></div><div id="result_div"></div></div>
<div id="hint_div">
⇒ interactive index to zvon materials
</div>
<div id="category_logo_div">
<table id="category-table">
<tbody><tr>
<td id="category-switch">
<img src="/shared/png/comp.png" height="66" width="70">
</td>
<td id="category-switch-links">
<div class="category-div">
<a href="/" id="switch-comp" class="switch-selected">
comp
<img src="/shared/png/comp_small.png" title="computing resources" style="display: none;" height="15" width="16">
</a>
</div>
<div class="category-div">
<a href="/law" id="switch-law">
law
<img src="/shared/png/law_small.png" title="international law documents" height="15" width="16">
</a>
</div>
<div class="category-div">
<a href="/lib" id="switch-lib">
lib
<img src="/shared/png/lib_small.png" title="resources for librarians" height="15" width="16">
</a>
</div>
<div class="category-div">
<a href="/eco" id="switch-eco">
eco
<img src="/shared/png/eco_small.png" title="eco resources" height="15" width="16">
</a>
</div>
</td>
</tr>
</tbody></table>
</div>
<div id="center" style="width: 500px;">
<div id="noscript" style="display: none;"><div id="noscript_intro">XPath is described in XPath 1.0 standard. In this tutorial selected XPath features are demonstrated on many examples.<br> <br> <div> <b>Standard excerpt:</b> </div> <blockquote class="webkit-indent-blockquote" style="BORDER:none;MARGIN:0 0 0 40px"> <div> XPath is the result of an effort to provide a common syntax and semantics for functionality shared between XSL Transformations and XPointer. The primary purpose of XPath is to address parts of an XML document. In support of this primary purpose, it also provides basic facilities for manipulation of strings, numbers and booleans. XPath uses a compact, non-XML syntax to facilitate use of XPath within URIs and XML attribute values. XPath operates on the abstract, logical structure of an XML document, rather than its surface syntax. XPath gets its name from its use of a path notation as in URLs for navigating through the hierarchical structure of an XML document. </div> </blockquote> <br> Zvon offers other XPath related materials.<br> <br> <b><br> </b> <div> <b>Prepared by:</b> Miloslav Nic (Mila)<span id="nicmila_details"></span> </div> <br></div></div>
<div id="center_top"></div>
<div id="center_middle"><h1 id="browser_title_line">XPath 1.0 Tutorial</h1><div id="prevNextDiv"><span id="backPageSpanPassive">Back</span>|<span id="forwardPageSpanPassive">Forward</span>||<span id="prevPageSpanPassive">Previous</span>|<span id="nextPageSpan">Next</span></div>**<div class="description">XPath is described in XPath 1.0 standard. In this tutorial selected XPath features are demonstrated on many examples.<br> <br> <div> <b>Standard excerpt:</b> </div> <blockquote class="webkit-indent-blockquote" style="BORDER:none;MARGIN:0 0 0 40px"> <div></div> </blockquote> <br> Zvon offers other XPath related materials XPath is the result of an effort to provide a common syntax and semantics for functionality shared between XSL Transformations and XPointer. The primary purpose of XPath is to address parts of an XML document. In support of this primary purpose, it also provides basic facilities for manipulation of strings, numbers and booleans. XPath uses a compact, non-XML syntax to facilitate use of XPath within URIs and XML attribute values. XPath operates on the abstract, logical structure of an XML document, rather than its surface syntax. XPath gets its name from its use of a path notation as in URLs for navigating through the hierarchical structure of an XML document. .<br> <br> <b><br> </b>** <div> <b>Prepared by:</b> Miloslav Nic (Mila)<span id="nicmila_details"></span> </div> <br></div><div id="prevNextDivBottom"><span id="prevPageSpanPassive">Previous</span>|<span id="nextPageSpan">Next</span></div></div>
<div id="center_bottom"><h2 class="bottom">XPath 1.0 Tutorial</h2><div id="front_keywords"><i>keywords</i>: programming, tutorial, XML, XPath</div> </div>
</div>
<div id="bottom"></div>
<div id="example_div">
<div id="example_menu_div" class="windowMenu">
<span id="close_example_span" class="windowMenuButton">x</span>
<span id="example_title_text" class="windowMenuText"></span>
</div>
<div id="example_body_div"></div>
</div>
</div>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1");</script><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<!--script src="/Javascript/jquery.min.js"></script-->
<script type="text/javascript" src="/Javascript/zvon.js"></script>
<script type="text/javascript">release="20100406"</script>
<script type="text/javascript">indexes={"_gadget": false, "_examples": [], "_display_format": {"Keywords": {"tp": "keyword", "title": ["name"]}, "Pages": {"tp": "page", "title": ["name"]}}, "_indexes": [["Pages", "page"], ["Keywords", "keyword"]], "Pages": ["List of XPaths", "XPath as filesystem addressing", "Start with //", "All elements: *", "Further conditions inside []", "Attributes", "Attribute values", "Nodes counting", "Playing with names of selected elements", "Length of string", "Combining XPaths with |", "Child axis", "Descendant axis", "Parent axis", "Ancestor axis", "Following-sibling axis", "Preceding-sibling axis", "Following axis", "Preceding axis", "Descendant-or-self axis", "Ancestor-or-self axis", "Orthogonal axes", "Numeric operations"], "_matID": "tut-XPath_1", "Keywords": ["", ">", "<", "*", "/", "//", "=", "#", "[]", "absolute path", "ancestor", "attribute", "axis", "ceiling", "child", "contains", "count", "descendant", "div", "division", "floor", "following", "last", "name", "normalize-space", "not", "parent", "preceding", "self", "sibling", "starts-with", "string", "string-length", "|"], "_title": "XPath 1.0 Tutorial"}</script>
<!-- script src="/Javascript/zvon_browser.js"></script>
<script src="/Javascript/zvon_xmlbrowser.js"></script -->
<!--script type="text/javascript">
$.get('http://c.zvon.org/counter/'+encodeURIComponent(window.location));
</script-->
<div id="dynamic_div" style="top: 100.133px; left: 259.5px;">
<div id="dynamic_menu_div" class="windowMenu">
<span id="close_dynamic_span" class="windowMenuButton">x</span>
<span id="dynamic_title_text" class="windowMenuText"></span>
</div>
<div id="inpDiv">
<div id="dynamic_pictogram" style="background-image: url("/shared/png/comp_small.png"); background-repeat: no-repeat;"></div>
<span id="inpStarts">
<input name="inp" value="start" checked="checked" type="radio">
starts with
</span>
<span id="inpContains" class="disabled">
<input name="inp" value="contains" type="radio">
contains
<span id="inpContains3chars"> (at least 3 characters needed)</span>
</span>
</div>
<div id="dynamic_body_div">
</div>
</div>
<img id="key" src="/shared/png/key.png" style="top: 100.133px; left: 119.5px;">
<!-- div id='adsense_right_top'>
<script type="text/javascript"><!- -
google_ad_client = "pub-8853328679404934";
/* refrences_top */
google_ad_slot = "9999918284";
google_ad_width = 234;
google_ad_height = 60;
//-->
<!--/script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div -->
You should disable javascript in your browser since scrapy doesn't render javascript and then inspect the source:
scrapy shell http://www.zvon.org/comp/r/tut-XPath_1.html
# disable javascript in your browser and:
view_response(response)
# now inspect the body for your fields
#i.e. this `response.css("div.description")` turns into:
response.css('div#noscript_intro')
I have a view that contains a Twitter Bootstrap nav nav-pills control. This is embedded fine, and in each of my tabs I am planning to embed two partial views. Below is the razor view
#using SiteNET.Models;
#using Microsoft.AspNet.Identity;
#model SiteNET.Models.ManageUserViewModel
#{
ViewBag.Title = "Manage Account";
}
<style type="text/css">
.manage {
margin: 20px;
}
</style>
<div class="manage">
<ul class="nav nav-pills" id="myTab">
<li><a data-toggle="tab" href="#manage">Manage Account</a></li>
<li><a data-toggle="tab" href="#downloads">Avalible Downloads</a></li>
</ul>
<div class="tab-content">
<div id="manage" class="tab-pane active fade in">
<h2>#ViewBag.Title</h2>
<p class="text-success">#ViewBag.StatusMessage</p>
#*<div class="alert alert-success"
data-toggle="collapse"
role="alert">#ViewBag.StatusMessage</div>*#
<div class="row">
<div class="col-md-12">
#Html.Partial("_ChangeEmailAddressPartial", Model)
</div>
</div>
<div class="row">
<div class="col-md-12">
#if (ViewBag.HasLocalPassword)
{
#Html.Partial("_ChangePasswordPartial")
}
else
{
#Html.Partial("_SetPasswordPartial")
}
</div>
</div>
#section Scripts {
#Scripts.Render("~/bundles/jqueryval")
}
</div>
<div id="downloads" class="tab-pane fade">
<h3>Downloads</h3>
<p>Avalible downloads partial view.</p>
</div>
</div>
</div>
The problem is that when the page loads the content of the first tab is shown but the actual tab is not selected (see below)
it should look like this when the page is first loaded
I have tried to use this solution, which uses the JavaScript below
<script>
$('#myTab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
// Store the currently selected tab in the hash value
$("ul.nav-tabs > li > a").on("shown.bs.tab", function (e) {
var id = $(e.target).attr("href").substr(1);
window.location.hash = id;
});
// On load of the page: switch to the currently selected tab
var hash = window.location.hash;
$('#myTab a[href="' + hash + '"]').tab('show');
</script>
But this does not seem to work (that is, does not seem to select the first tab when the page is loaded). It also does not store the selected tab. How can I
Make the first tab show as selected when the page is first loaded?
How can I amend the JS above so that the selected tab is persisted between page navigations?
Thanks for your time.
To see this problem for your self go to CodeLAB and paste in
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Twitter Bootstrap 3 Pills Nav with Icons</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<style type="text/css">
.bs-example{
margin: 20px;
}
</style>
</head>
<body>
<script>
//$('#myTab a[href="manage"]').tab('show');
$('#myTab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
// Store the currently selected tab in the hash value
$("ul#myTab > li > a").on("shown.bs.tab", function (e) {
var id = $(e.target).attr("href").substr(1);
window.location.hash = id;
});
//$("ul.nav-tabs > li > a").on("shown.bs.tab", function (e) {
// var id = $(e.target).attr("href").substr(1);
// window.location.hash = id;
//});
// On load of the page: switch to the currently selected tab
var hash = window.location.hash;
$('#myTab a[href="#' + hash + '"]').tab('show');
</script>
<div class="manage">
<ul class="nav nav-pills" id="myTab">
<li><a data-toggle="tab" href="#manage">Manage Account</a></li>
<li><a data-toggle="tab" href="#downloads">Avalible Downloads</a></li>
</ul>
<div class="tab-content">
<div id="manage" class="tab-pane active fade in">
<h2>Manage</h2>
<p class="text-success">Success</p>
<div class="row">
<div class="col-md-12">
<p>Partial view A</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p>Partial view B</p>
</div>
</div>
</div>
<div id="downloads" class="tab-pane fade">
<h3>Downloads</h3>
<p>Avalible downloads partial view.</p>
</div>
</div>
</div>
</body>
</html>
Then click "Show Output", you will see the problem.
I have no experience with asp and whatsoever, but for the bootstrap / jQuery part I guess your solution is this:
1.) Give the li you want to be active the class .active. For example:
<li class="active"><a data-toggle="tab" href="#manage">Manage Account</a></li>
The same goes than for the according content element, like you already did.
<div id="manage" class="tab-pane active fade in">xxx</div>
Take a closer look to the according bootstrap documentation: Bootstrap Tabs
2.) I guess it's not working because your script targets the wrong element (ul.nav-tabs), which doesn't exist in your code. As far as I can see it from your code, you have .nav-pills instead. So try:
$("ul.nav-pills > li > a").on("shown.bs.tab", function (e) {
var id = $(e.target).attr("href").substr(1);
window.location.hash = id;
});
Or even better, try targeting your unique id #myTab, like this:
$("ul#myTab > li > a").on("shown.bs.tab", function (e) {
var id = $(e.target).attr("href").substr(1);
window.location.hash = id;
});
If this doesn't help or hint you in the right direction, please try to create a working fiddle of your generated html output so that we can take a closer look at your code.
UPDATE
Try this code. It works perfectly for me on my localhost.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Twitter Bootstrap 3 Pills Nav with Icons</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<style type="text/css">
.bs-example{
margin: 20px;
}
</style>
</head>
<body>
<script>
$(document).ready(function() {
if(location.hash) {
$('a[href=' + location.hash + ']').tab('show');
}
$(document.body).on("click", "a[data-toggle]", function(event) {
location.hash = this.getAttribute("href");
});
});
$(window).on('popstate', function() {
var anchor = location.hash || $("a[data-toggle=tab]").first().attr("href");
$('a[href=' + anchor + ']').tab('show');
});
</script>
<div class="manage">
<ul class="nav nav-pills" id="myTab">
<li class="active"><a data-toggle="tab" href="#manage">Manage Account</a></li>
<li><a data-toggle="tab" href="#downloads">Avalible Downloads</a></li>
</ul>
<div class="tab-content">
<div id="manage" class="tab-pane active fade in">
<h2>Manage</h2>
<p class="text-success">Success</p>
<div class="row">
<div class="col-md-12">
<p>Partial view A</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p>Partial view B</p>
</div>
</div>
</div>
<div id="downloads" class="tab-pane fade">
<h3>Downloads</h3>
<p>Avalible downloads partial view.</p>
</div>
</div>
</div>
I was trying to include an HTML file in another HTML File div like follows,
<body>
<form action="#" method="post">
<div class="container">
<div class="sidebar">
<!-- Do not insert any tags here -->
</div>
<div class="contentbody">
<div class="titlearea">
<div class="userprofile"></div>
<div class="pageheading">
<h1>Page Heading</h1>
</div>
</div>
<div class="formarea">
<!-- This is where I have to put the html page which contains a navigatin menu-->
<!--#include virtual="menuset1.html" -->
</div>
</div>
</div>
</form>
But when I run it on chrome it doesn't show up (menuset1), when I test it on dreamweaver it appears from behind of all elements and not in the correct position, Please guide me on this.
I think you should use jquery like,
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
....
....
<script>
$(function(){
$(".formarea").load("menuset1.html");
});
</script>
Or use PHP like,
<div class="formarea">
<?php
include('menuset1.html');
?>
</div>
Read php inclusion of files
I'm currently building a website but I noticed the slider doesn't work in IE8. When I click on the compatibility mode button it does work.
It shows some strangely misplaced divs when I viewed in IE8. I recently built in Pie for the rounded corners to work in IE8; maybe that's the problem with the slider?
Is there anyone that can help me?
Here's the code :)
<div class="slider-container">
<div id="slideshow">
<div>
<div class="caption rc">
<div class="caption-text">
<?php perch_content('tekst slide 1'); ?>
</div>
</div>
<img src="img/slider.jpg" alt="Slide">
</div>
<div>
<div class="caption rc">
<div class="caption-text">
<?php perch_content('tekst slide 2'); ?>
</div>
</div>
<img src="img/slider-2.jpg" alt="Slide">
</div>
<div>
<div class="caption rc">
<div class="caption-text">
<?php perch_content('tekst slide 3'); ?>
</div>
</div>
<img src="img/slider-3.jpg" alt="Slide">
</div>
<div>
<div class="caption rc">
<div class="caption-text">
<?php perch_content('tekst slide 4'); ?>
</div>
</div>
<img src="img/slider-4.jpg" alt="Slide">
</div>
</div>
</div>
And here:
$(function() {
$("#slideshow > div:gt(0)").hide();
setInterval(function() {
$('#slideshow > div:first')
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo('#slideshow');
}, 6000);
});
The strange thing is that it will work in compatibility mode, but not in normal mode, in IE8 and in Firefox, Chrome, and Safari it's working fine.
You are using a cdn, sometimes there is trouble loading cdn files...
Try adding a fallback script to load jquery from your local server.
Add this after your jquery script from google cdn in the header and modify your path.
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='path to jquery libary' type='text/javascript'%3E%3C/script%3E"));
}
</script>
Hope this helps
regards