how to get form field value in JQuery

JQuery Form Value Example

Simple JQuery example to get the HTML form field value using JQuery. HTML contains various element like text field, text area, radio button, check boxes etc. You can easily get the value of form field using JQuery.

jquery example
 

This tutorial explain you how to get the text field and text area value using JQuery.

To get value of HTMLinput field.


$("input").val();

 

To get value of HTML Text area field.


$("textarea").val();

 

JQuery example

<!DOCTYPE html>

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

<script>

$(document).ready(function(){

$("button").click(function(){

alert("Text field value- " + $("#test").val());

alert("Text area value- " + $("#test1").val());

});

});

</script>

</head>

<body>



Name: <input type="text" id="test" value="umar farooque">


<textarea id="test1">

ptutorial

</textarea>

<button>Get form field values</button>

</body>

</html>

To learn more about JQuery example and see a lot of live example visit: JQuery Example

Do not forgot to like share and comment

 



Java program to remove string spaces

Java program to remove string spaces ?

Java program to remove leading and trailing spaces from string – the following java program or java source code to remove the space from string using toCharArray() and length with the help of for loop. The toCharArray() is used to convert the string to the character array and length is used to get the length of string.

java example

class A8

{

public static void main(String arr[])

{

int x[],i=0,j=0;

String s="        UmarKhan     ";

char ch[]=s.toCharArray();

int c=ch.length;

x=new int;

for(i=0;i<c;i++)

{


x[i]=ch[i];

}

for(i=0;i<c;i++)

{

if(x[i]!=32)

{

j=i;

break;

}

}

for(i=c-1;i>=0;i--)

{

if(x[i]!=32)

{

c=i;

break;

}

}

for(i=j;i<=c;i++)

System.out.print(ch[i]);

}

}

output

UmarKhan

The following java source code removes the leading and trailing spaces only not in between spaces.

 

For more c example, c tutorial orc tutorial and example PDF visit – java example

Do not forgot to like share and comment



how to swap two numbers without using a third variable

How to swap two numbers without using a third variable ?

C program to swap two numbers without using third variable, swapping means changing the data from one variable to other variable see the following example-

You have two variable a and b with value

a=10 
b=20

 

Then the result after and before swapping is like that

Before swapping

a=10
b=20

After swapping

a=10
b=20

 

The below c program swap or c example the numbers without using third variable. You can swap the number by using third variable also. See the example in next section.

C program to swapp numbers

#include <stdio.h>
#include <conio.h>
 
void main()
{
   int firstnumber, secondnumber, temp;
 
   printf("Enter the value of firstnumber and secondnumber\n");
   scanf("%d%d", &firstnumber, &secondnumber);
 
   printf("Before Swapping\nfirstnumber = %d\nsecondnumber = %d\n",firstnumber,secondnumber);
 
   temp = firstnumber;
   firstnumber    = secondnumber;
   secondnumber    = temp;
 
   printf("After Swapping\nfirstnumber = %d\nsecondnumber = %d\n",firstnumber,secondnumber);
 
   getch();
}

 

 

For more c example, c tutorial orc tutorial and example PDF visit C Example

Do not forgot to like share and comment