VTU Solution of 16MCA42 Advanced Web Programming June 2018 - Uma B
VTU Solution of 16MCA42 Advanced Web Programming June 2018 - Uma B
<html>
<head>
src =
"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery
.min.js">
</script>
$(document).ready(function() {
});
</script>
</head>
<body>
</div>
</div>
</div>
</body>
</html>
2 a.
parent > $("div > p") All <p> elements that are
child a direct child of a <div>
element
parent $("div p") All <p> elements that are
descendant descendants of a <div>
element
b.
$(document).ready(function(){
$(p).click(function(){
var sd=$(this).text();
var num = sd.match(/[\d\.]+/g);
if (num != null){
var number = num.toString();
alert(number );
}
});
});
Module - 2
<?php
# comments.php
# Author Jan Bodnar
# ZetCode 2016
?>
// comments.php
// author Jan Bodnar
// ZetCode 2016
/*
comments.php
author Jan Bodnar
ZetCode 2016
*/
public $isRunning;
$a=1;
$b = 2;
$c = 3;
$a = 1;
$b = 2; $c = 3;
$d
=
4;
PHP semicolon
$a = 34;
$b = $a * 34 - 34;
echo $a;
PHP variables
$Value
$value2
$company_name
$12Val
$exx$
$first-name
case.php
<?php
$number = 10;
$Number = 11;
$NUMBER = 12;
echo "\n";
?>
$ php case.php
101112
PHP constants
constants.php
<?php
define("SIZE", 300);
define("EDGE", 100);
#SIZE = 100;
echo SIZE;
echo EDGE;
echo "\n";
?>
define("SIZE", 300);
define("EDGE", 100);
#SIZE = 100;
$ php constants.php
300100
PHP literal
$age = 29;
$nationality = "Hungarian";
literals.php
<?php
$ php literals.php
Patrick 34
Luke 22
Jane 17
Rose 16
PHP operators
+ - * / % ++ --
= += -= *= /= .= %=
== != >< > < >= <=
&& || ! xor or
& ^ | ~ . << >>
PHP delimiters
$a = "PHP";
$b = 'Java';
function setDate($date) {
$this->date = $data;
}
if ( $a > $b) {
echo "\$a is bigger than \$b";
}
$a = array(1, 2, 3);
echo $a[1];
/*
Author Jan Bodnar
January 2016
ZetCode
*/
<?php
// PHP code
?>
The <?php and ?> delimiters are used to delimit PHP code
in a file.
PHP keywords
3b. <?php
If($_POST[“textfieldname”]=”value”)
Echo “ correct”;
$unixTime = Time();
print date("m/d/y h:i:s a", $unixTime);
if (isset($gender) && $gender=="male") echo "checked";
if (is_numeric($element)) {
echo var_export($element, true) . " is numeric", P
HP_EOL;
}
4a.
Function Description
addcslashes() Returns a string with backslashes in
front of the specified characters
4b.
To create a cookie
Setcookie(name,value,expires,path);
Example:
<?php
Setcookie(‘username’,’abcd’,time()+4800);
?>
Example:
<?php
?>
To delete a cookie
<?php
Setcookie(“username”,””,time()-4800);
?>
Sessions
To start a session
Session_start();
<?php
Session_start();
$_SESSION[“username”] = “abc”;
?>
Unset($_SESSION[“username”]);
Module – 3
5a.
Input
Gets
gets.to_i
Gets.chomp
Output
Puts
5b.
the_file='/Users/Al/DD/Ruby/GettysburgAddress.txt'
h = Hash.new
f = File.open(the_file, "r")
f.each_line { |line|
words = line.split
words.each { |w|
if h.has_key?(w)
h[w] = h[w] + 1
else
h[w] = 1
end
5c.
Form
To create a form tag with the specified action, and with
POST request, use the following syntax −
ext Fields
To create a text field use the following syntax −
Text Area
To create a text area, use the following syntax −
<%= text_area "post", "body", "cols" => 20, "rows" => 40%>
This will generate the following code −
<%={@post.body}%>
</textarea>
Radio Button
To create a Radio Button, use the following syntax −
Checkbox Button
To create a Checkbox Button use the following syntax −
check_box("post", "validated")
Options
To create a dropdopwn list, use the following syntax −
<%= select
:variable,:attribute,choices,options,html_options%>
Date Time
Following is the syntax to use data and time −
6a.
#!/usr/bin/ruby
digits = Array(0..9)
num = digits.at(6)
puts "#{num}"
Traditional web are built with HTML and CSS、CGI and had
been offered as a static page . On the other hand Web 2.0
uses Ajax(Asynchronous JavaScript + XML) presenting
dynamic , rich user experience to users .
,(comma )
{
"book": [
{
"id":"01",
"language": "Java",
"edition": "third",
"author": "Herbert Schildt"
},
{
"id":"07",
"language": "C++",
"edition": "second"
"author": "E.Balagurusamy"
}]
}
8 Explain REST?
b
. Representational State Transfer (REST) is an
architectural style that specifies constraints, such
as the uniform interface, that if applied to a web
service induce desirable properties, such as
performance, scalability, and modifiability, that
enable services to work best on the Web.
HTTP Methods
Following well known HTTP methods are commonly used
in REST based architecture.
GET - Provides a read only access to a resource.
8c.
SOAP
SOAP is an XML-based protocol for exchanging information
between computers.
SOAP is a communication protocol.
SOAP is for communication between applications.
SOAP is a format for sending messages.
SOAP is designed to communicate via Internet.
SOAP is platform independent.
SOAP is language independent.
SOAP is simple and extensible.
SOAP allows you to get around firewalls.
SOAP will be developed as a W3C standard.
WSDL
WSDL is an XML-based language for describing web services
and how to access them.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
.domain([d3.min(data), d3.max(data)])
.range([100, 400]);
.append("svg")
.attr("width", width)
var g = svg.selectAll("g")
.data(data)
.enter()
.append("g")
});
g.append("rect")
//console.log(scale(d))
return scale(d);
})
.attr("height", barHeight - margin)
g.append("text")
.attr("y", barHeight / 2)
</script>
</body>
</html>
10a.
10b.
<body>
<svg width="300" height="200"> </svg>
<script>
var data = [2, 4, 8, 10];
var color =
d3.scaleOrdinal(['#4daf4a','#377eb8','#ff7f00','#984ea3','
#e41a1c']);
//Generate groups
var arcs = g.selectAll("arc")
.data(pie(data))
.enter()
.append("g")
.attr("class", "arc")