auto populated field
Moderator: General Moderators
auto populated field
some please help.
I need to know what code should i put on my field to make other field auto populated.
look at this.
these are my fields:
field_firstname
field_lastname
field_email
field_username
when i input my firstname and lastname i want my email and username to be auto fill.
for example:
firstname: john- manually
lastname: laurence - manually
username: john.laurence - auto fill in
email: john.laurence - auto fill in
many thanks.
I need to know what code should i put on my field to make other field auto populated.
look at this.
these are my fields:
field_firstname
field_lastname
field_email
field_username
when i input my firstname and lastname i want my email and username to be auto fill.
for example:
firstname: john- manually
lastname: laurence - manually
username: john.laurence - auto fill in
email: john.laurence - auto fill in
many thanks.
Re: auto populated field
Hi U need to use javascript or jquery .Check this Link http://jsfiddle.net/d5bHp/. Hope it helps
Re: auto populated field
Hi Gopesh
thanks for a post. but it seems i have a problem
my form didnt work so fine. thanks
thanks for a post. but it seems i have a problem
Code: Select all
<head>
<title> MY TITLE </title>
<script type="text/javascript">
$('#fname, #lname').bind('keyup blur', function() {
$('#uname,#email').val($('#fname').val() + '.' +$('#lname').val());
});
</script>
</head>
<body>
FirstName:<input type="text" id="fname" class="populate"><br/><br/>
LastName:<input type="text" id="lname" class="populate"><br/><br/>
UserName:<input type="text" id="uname" value=""><br/><br/>
Email:<input type="text" id="email" value="">
</body>
</html>
Last edited by Benjamin on Sun Dec 11, 2011 8:46 am, edited 1 time in total.
Reason: Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
Reason: Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
Re: auto populated field
I copy and paste all the codes in javascript and html to my form and I attached the javascript inside of <head> tags but when i try to run the code. It didnt work. Do i have to add something in my head tags? thanks
Re: auto populated field
Hi,u need to include the jquery library file in the head section.For this,u need to download the jquery library from jquery site and mention the path in the src
Tip: Inorder to view the javascript & jquery errors,
1. use firebug
2.press ctrl+shift+j,error console will open and it displays the javascript errors.
Note:Both will work only on Firefox.
Code: Select all
<script type="text/javascript" src="jquery-1.6.4.js"></script>
1. use firebug
2.press ctrl+shift+j,error console will open and it displays the javascript errors.
Note:Both will work only on Firefox.
Re: auto populated field
thanks Gopesh!
it still not working.
do i have wrong syntax?
I downloaded the jquery-1.6.4.js and place to the same folder of populate.php.
Code: Select all
<html>
<head><script type="text/javascript" src="jquery-1.6.4.js">
$('#fname, #lname').bind('keyup blur', function() {
$('#uname,#email').val($('#fname').val() + '.' +$('#lname').val());
});
</script></head>
<body>
FirstName:<input type="text" id="fname" class="populate"><br/><br/>
LastName:<input type="text" id="lname" class="populate"><br/><br/>
UserName:<input type="text" id="uname" value=""><br/><br/>
Email:<input type="text" id="email" value="">
</body>
</html>I downloaded the jquery-1.6.4.js and place to the same folder of populate.php.
Last edited by Benjamin on Sun Dec 11, 2011 8:45 am, edited 1 time in total.
Reason: Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
Reason: Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
Re: auto populated field
Hi,here is the problem.
Pls close the script tag properly like this<head><script type="text/javascript" src="jquery-1.6.4.js">
$('#fname, #lname').bind('keyup blur', function() {
$('#uname,#email').val($('#fname').val() + '.' +$('#lname').val());
});
</script></head>
Code: Select all
<head><script type="text/javascript" src="jquery-1.6.4.js"></script>
<script>
$('#fname, #lname').bind('keyup blur', function() {
$('#uname,#email').val($('#fname').val() + '.' +$('#lname').val());
});
</script></head>
Re: auto populated field
Hi Gopesh,
You're the man dude! but it seems i have a big problem.
You're the man dude! but it seems i have a big problem.
Code: Select all
<html>
<head>
<head><script type="text/javascript" src="jquery-1.6.4.js"></script>
<script>
$('#fname, #lname').bind('keyup blur', function() {
$('#uname,#email').val($('#fname').val() + '.' +$('#lname').val());
});
</script></head>
</head>
<body>
FirstName:<input type="text" id="fname" class="populate"><br/><br/>
LastName:<input type="text" id="lname" class="populate"><br/><br/>
UserName:<input type="text" id="uname" value=""><br/><br/>
Email:<input type="text" id="email" value="">
</body>
</html>
Last edited by Benjamin on Sun Dec 11, 2011 8:45 am, edited 1 time in total.
Reason: Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
Reason: Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
Re: auto populated field
still not working 
Re: auto populated field
Hi,It is because of missing $(document).ready().Try this
Try to debug the page as i mentioned earlier.Then it is easy to understand what is the error.Hope it helps u
Code: Select all
<html>
<head><script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script>
$(document).ready(function() {
$('#fname, #lname').bind('keyup blur', function() {
$('#uname,#email').val($('#fname').val() + '.' +$('#lname').val());
});
});
</script></head>
<body>
FirstName:<input type="text" id="fname" class="populate"><br/><br/>
LastName:<input type="text" id="lname" class="populate"><br/><br/>
UserName:<input type="text" id="uname" value=""><br/><br/>
Email:<input type="text" id="email" value="">
</body>
</html>
Re: auto populated field
thanks dude!
what if i want to add on my email
ex. john.ken@company.com auto fill also? can i do that?
what if i want to add on my email
ex. john.ken@company.com auto fill also? can i do that?
Re: auto populated field
Hi, check this http://jsfiddle.net/d5bHp/2/ .I think there is more another efficent method to do it.It is not the right area to discuss jquery related problems.For those queries Use javascript section. Hope it helps u.
Re: auto populated field
Do you want to auto-fill on page load? i.e. if the person submits the form but is missing a field, the values they entered will re-appear in the form?
You haven't given us much information as to when you want to do this or where the data is coming from, so saying Javascript is the solution is a bit presumptuous.
You haven't given us much information as to when you want to do this or where the data is coming from, so saying Javascript is the solution is a bit presumptuous.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: auto populated field
Hi Gopesh!
Thankssssssssss alot dude! you really help me a lot. long live! Godbless
Thankssssssssss alot dude! you really help me a lot. long live! Godbless
Re: auto populated field
Welcome..Hope that u got the idea to solve the problem.