473,730 Members | 4,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populate second text box based on value extracted from first text box

82 New Member
I have to extract the value entered in the first text box and based on the value entered have to populate the second text box.
Eg:if the value entered in first text box is like home/version then I have to extract the home and version entered in the text box and the second text box should contain home/version along with that it should contain additional say date information home/version/date.
Can somebody help me do it?

Oct 15 '08
51 6887
82 New Member
if the function is not present in the present page then how do I access that function in the javascript function??
Oct 16 '08 #11
16,027 Recognized Expert Moderator MVP
Then include it using script tags, e.g.
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="file.js"></script>
Oct 16 '08 #12
82 New Member
Actually what I wanted is the values b[0] and b[1] has to be passed to a php function where the processing will be done and then the result of that php function has to be returned to the setAttribute.
Oct 16 '08 #13
16,027 Recognized Expert Moderator MVP
Why didn't you say that earlier?! ;)

What you need is Ajax (if you want to avoid a page reload) unless you can convert the PHP function to JavaScript. If you're new to Ajax, check out the links in the Off-site Links sticky.
Oct 16 '08 #14
82 New Member
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.      $c=$_GET['c'];
  3.      $d=$_GET['d'];
  4.      if($c=="cat") {
  5.         $e=$d.$c;
  6.         }
  7.      ?>
  8. <script type='text/javascript'>
  9. function test1()
  10. {
  11.      var a = document.getElementById("first").value;
  12.      var b = a.split('/');
  13.       var d =b[0];
  14.       var c = b[1];
  15.       if( b[0] ==  "dog"){
  16.       location.href="c.php?d="+d+"&c="+c;
  17.        var js= <?php echo $e; ?>
  18.        document.getElementById("second").setAttribute("value",js);
  19.        }
  20. }
  22. </script>
  23. <body>
  24. <input type="text" id="first" size="40" onKeyUp="test1();"/><br><br>
  25. <input type="text" id="second" size="40"/>
  26. </body>
what is wrong with this code??
Oct 16 '08 #15
16,027 Recognized Expert Moderator MVP
A lot. You need to put the PHP code in a separate file. To use Ajax, you need to use the XMLHttpRequest object, not location.href. Get a simple Ajax page working first and then extend to your particular problem.
Oct 16 '08 #16
82 New Member
I am new to this javascript so can anyone please tell me how can my problem be solved using ajax.
Oct 16 '08 #17
16,027 Recognized Expert Moderator MVP
Have you tried one or two of the tutorials in the thread I linked to? Get that working and understand it first, then you can work on your problem.
Oct 16 '08 #18
82 New Member
Can you please help me with the code its urgent:(
Oct 16 '08 #19
16,027 Recognized Expert Moderator MVP
I can't do it for you, but I can help. Is the latest version of your code still the one you posted in post #15?
Oct 16 '08 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Swadh | last post by:
Hi, I need urgent help on Windows Form datagrid. I have to Display a datagrid that has a textbox column and another one combo box column. I have two tables in my Access database as: Table 1: Columns: Part_ID, Descr Here Part_ID is Primary key. Table 2:
by: Alonso | last post by:
Hi, I have two drop downs and the content of the second one must changed everytime the user changes the selection in the first one. Is any easy way of doing this? Thanks in advance. Alonso
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp page. I am able to call values from file in my jsp page. But as dynamic values can be any in no...
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp page.But as dynamic values can be any in no i don't know how could i populate all those in my jsp...
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and the Dropdown doesnt have any items.. The requirement is that as soon as one goes on typing the letters in the StudentName-textbox the corresponding matching names have to appear
by: joseph.mccastlain | last post by:
Hello All, I am a new user to Access. I am currently designing a database consisting of four tables for multiple users. Rather than bore you with the goals and such, here is what I am attempting to do: I have two combo boxes, the first of which contains three text values (Org 1, Org 2, Org 3) and the second combo box contains a listing of 30 or so clients. I would like to condense the second combo box based upon the selection of the...
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt tbl_Input has three fields: OSE_Job, OSE_Name, OSE_Wt I have populated tbl_OSE_Info table. I need to create a form that will store the data in tbl_Input I have racked my brain so much trying to figure out how to auto populate a field based on a...
by: Ronald | last post by:
I hope somebody can help. I can't get into the specifics of my project, but I'll try to create a simple example: tblVehicle * VIN (text box) * Make (text box) * Model (text box) frmRepair
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The frontend that users will see however, still needs some work. I'm really close, but since I'm no...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.