Вы находитесь на странице: 1из 5

WT LAB

III B. Tech CSE Section: A

Regd. No.: Week: Date:


17R21A0546 05 25-9-2019

1.Write an HTML page that has one input, which can take multi-line text and a submit button. Once the user
clicks the submit button, it should show the number of characters, words and lines in the text entered using
an alert message. Words are separated with white space and lines are separated with new line character.

<html>

<script type="text/javascript">

function counts() {

var textarea=document.getElementById("tarea");

var text = textarea.value;

chars = text.length,

words = text.split(/\s+/).length - 1,

lines = text.split("\n").length - 1;

value = lines + " lines, " + words + " words, " + chars + " characters";

alert(value);

</script>

<form name="cwl">

Enter Multi Line Text <br>

<textarea name="string" id="tarea" rows=4 cols=30></textarea>

<input type="button" name="sub" value="submit" onClick="counts()">

</form> </html>

OUTPUT:
2.Create an XML document that contains 10 users information. Write a Java program, which takes User Id as
input and returns the user details by taking the user information from the XML document

<?xml version="1.0"?>

<college>

<student>

<id>501</id>

<name>Deepa</name>

<branch>cse</branch>

</student>

<student>

<id>502</id>

<name>annie</name>

<branch>ece</branch>

</student>

<student>

<id>503</id>

<name>shivani</name>

<branch>it</branch>

</student>

<student>

<id>503</id>

<name>munni</name>

<branch>cse</branch>

</student>
<student>

<id>504</id>

<name>viju</name>

<branch>eee</branch>

</student>

<student>

<id>505</id>

<name>sai</name>

<branch>cse</branch>

</student>

<student>

<id>506</id>

<name>chay</name>

<branch>mech</branch>

</student>

<student>

<id>507</id>

<name>giva</name>

<branch>eee</branch>

</student>

<student>

<id>508</id>

<name>Daniel</name>

<branch>cse</branch>

</student>

<student>

<id>509</id>

<name>Disha</name>

<branch>eee</branch>

</student>

<student>
<id>510</id>

<name>shawn</name>

<branch>ece</branch>

</student>

</college>

Html:

<html>

<head><title>load</title>

<body>

<form method="POST" action="5.php">

userid:<input type="text" name="user" value="user">

<input type="submit" name="submit">

</form>

</body>

</html>

Php

<?php

$y=$_POST["user"];

//echo $y;

$us=simplexml_load_file("p.xml");

//print_r($users);

foreach($us->student as $users)

if($y==$users->id)

echo "username: ".$users->name;

echo "\n";

echo "branch: ".$users->branch;

}
o/p:

Вам также может понравиться