Student Plus - A great resource to be intermediate to expert in different fields like jquery, css, html, php, joomla, javascript, css3, html5, mysql etc.
Scrollable content area is looking more beautiful when we add some jquery events on it, beside this it will possible throught javascript as well, to make two functions that will call on the mouseover and the mouseout html attributes. But in this example we make it more easy with the help of .hover() event represented by jquery. You will found more about the .hover() event on the jquery official website.
Ajax request is the most powerful feature of jquery, it helps to send data over the cross domain in the backend. In this post i give the very basic idea to submitaformwithpagerefreshing and get the result. In this script i use some basic jquery and php. If you will apply this script in your own page then, I request you to validate all the data. Lets beautify the form with some CSS codes:
I use table to prevent the browser confliction bug. Now lets start with some jquery stuff, before applying this stuff please insert the jquery source file from jquery official site or form ajax google api.
If we talk about the Data Represent into the Website than it is better the best way to display your data into tables, cause IE6 creates lots of problem to in CSS to align the data. And Jquery plays his important roll to beautify that tables Data. The :even, :odd selectors make it beautiful to represent the data. Here is an example :
$('table').css({
'border-collapse':'collapse'
});
$('tr th').css({'background':'#666666', 'color':'#ffffff', 'font-family':'verdana', 'font-weight':'normal'});
// Here using jquery selectors
$('tr:even').css({'background':'#c3c3c3'});
$('tr:odd').css({'background':'#e3e3e3'});
Getting URL or URL parts through javascript is so easy. We can get protocal using this code :
var proto = window.location.protocol;
alert( proto );
this code return "http:" protocol.
If you want to get host name from the URL using javascript then you can simple write this code:
var hostName = window.location.host;
alert( hostName );
this code return the host name like if you are running this code in local host then it returns "localhost"
if you want to get path of the URL with javascript then use this:
var pathName = window.location.pathname;
alert( pathName );
this code returns the path name of the current running script like you are running the script in test.html the it return the full path name with filename test.html
Or if you want to get parameter used in URL with javascript then simply do this:
var params = window.location.search;
alert( params );
it returns the parameter used in the URL
now lets join all the code :
var proto = window.location.protocol;
var hostName = window.location.host;
var pathName = window.location.pathname;
var params = window.location.search;
alert( proto + hostName + pathName + params );
hello friends last Saturday i was working on a Real State project and i need to build a dynamic form to submit the properties in particular state and cities. I made that dynamic form with the help of php and jquery. Here is i describe the codes one by one.
First of all we need to create a Database. And after that Create Some tables related to your project. I Create a Database name 'test' in phpmyadmin. My these codes are related to this dynamic form you can change the Database name and fields as per your requirements. After create the database create a table, in this example i create a table name 'tbl_class' with these codes :
now create one more file 'index.php' and create some html stuff.
for example :
Dynamic Form
include the 'connection.php' file on the top of the 'index.php', like:
include 'connection.php';
then insert the data in the select option
#insert class data from database
$query = "select * from tbl_class";
$result = mysql_query($query) or die("Error in Query!
".mysql_error());
while($row = mysql_fetch_array( $result ))
{
echo "";
}
now it is the time to use jquery for the ajax request. Create a function with jquery to make simple the ajax request.
here is the code for the ajax request function:
create a 'getStrength.php' file to get the data through ajax request.
if(isset($_REQUEST['class']))
{
$classID = (int)$_REQUEST['class'];
$query = "select * from tbl_student where classID = '$classID'";
$result = mysql_query( $query ) or die("Error in Strength Query!");
if($classID == 0)
echo '';
else{
while($row = mysql_fetch_array($result)){
echo "";
}
}
}
the above code is for the file 'getStrength.php'. The ajax request send the data to this file and get the result through this file.
You can beautify this dynamic form with some css effects.
Form validation is must to prevent spam and form attacks. Email validation is also must to making a form. We use Regular Expressions for validation in PHP, which is secure and highly usable on web. preg_match() and ereg() functions are using for validation. But sometimes ereg() function produce some Deprecated Error. To prevent Deprecated Error we use preg_match for email validation. Here are some codes for Email Validation :
function email_Validate($str)
{
if(preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $str))
{
return true;
}
}
if(!email_Validate($email))
{
echo "Email not valid!";
}
Beside PHP you can validate your email with javascript/jquery. Its quite easy to implement and use with the help of javascript/jquery. Here is my code for jquery and you can also implement these with javascript :
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
//userMail is a input box name
var email = $('#userMail').val();
if(reg.test(email) == false)
{
alert('Email Not Valid');
}
this validation help you to prevent spamming in login system or registration form.