473,804 Members | 4,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Focus in Textbox when the page is Loaded through Ajax

14 New Member
Hi,

This is ram.

I am developing a page(usereg.jsp ) with two textboxes one for username and another for email. Since i am using this page in main.jsp using Ajax, I am removing the body part in usereg.jsp.

Now i need to focus the cursor in first textbox of usereg.jsp. Since there is no body tag in this jsp i cannot call onload="documen t.formname.text boxname.focus() ".

But i need the focus in textbox when i call this page in main.jsp.

Even i have tried to focus the texbox in usereg.jsp by writing the seperate java script in this page. When i execute just this page(usereg.jsp ) the problem of focusing text box is solved,,

But when i call this page in main.jsp along with the java script i wrote, the focus is not reflecting.

Please suggest me where am i going wrong..

my mailid is: ****
Feb 25 '07
33 3987
webhead
56 New Member
Because http actually *isn't* automatically assigning a value to response. I went back and looked at my AJAX frameworks, and it turns out that you have to manually do this.

Yeah. *sheepish grin*

So anyway, here's what initAjax *really* should look like (are we having fun yet?):
Having fun... like the time our driver's ed instructor hit the car in front when we asked him to show us parallel parking with real cars instead of cones... 8-)

Expand|Select|Wrap|Line Numbers
  1. function initAjax(url, callback) {
  2.     var http = getHTTPObject(); 
  3.     http.open("GET", url, true);
  4.     http.onreadystatechange = function() {
  5.         if (http.readyState == 4) { callback(http); } 
  6.         };
  7.     http.send(null);
  8.     }
w00t! It lives!

But.... ::sobbing:: ... now there's no focus :-(
Expand|Select|Wrap|Line Numbers
  1. function initAjax(url, callback) {
  2.     var http = getHTTPObject(); 
  3.     http.open("GET", url, true);
  4.     http.onreadystatechange = function() {
  5.         if (http.readyState == 4) { callback(http); } 
  6.         };
  7.     http.send(null);
  8.     }
  9.  
  10. function getTestpage() { 
  11.     url = "afunc.php";
  12.     initAjax(url, function (response) { 
  13.             document.getElementById(theOutput).innerHTML = response.responseText;
  14.             fldname.focus();
  15.         });
  16.     }    
May 14 '07 #31
pbmods
5,821 Recognized Expert Expert
But.... ::sobbing:: ... now there's no focus :-(
Hm. Your code is looking pretty good. The only thing I can think of is that fldname is not defined.

Check your error console and see what's going on.
May 14 '07 #32
webhead
56 New Member
Hm. Your code is looking pretty good. The only thing I can think of is that fldname is not defined.

Check your error console and see what's going on.
This works:
Expand|Select|Wrap|Line Numbers
  1. function getTestpage() { 
  2.     url = "afunc.php";
  3.     initAjax(url, function (response) { 
  4.             document.getElementById(theOutput).innerHTML = response.responseText;
  5.             document.getElementById('fldname').focus();
  6.         });
  7.     }    
Whew!

Felt like wandering in the desert for 40 years just to go 20 miles, but worth the trip because things were learned. Thanks again for all your help. :-)
May 14 '07 #33
pbmods
5,821 Recognized Expert Expert
Felt like wandering in the desert for 40 years just to go 20 miles, but worth the trip because things were learned.
On both sides (both parts :P).

Thanks again for all your help. :-)
You are most welcome. Come back anytime!
May 14 '07 #34

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

Similar topics

1
1767
by: Gill Smith | last post by:
when the page is loaded I am using onload event at the client side and setting the focus on the control(TextBox). However when the user clicks on Clear ImageButton, I am clearing all the text boxes and the grid(previous search result display) in the clicked event of the ImageButton at the server side. How to set the focus on the TextBox again when the user clicks on the Clear button. -Gill
3
1193
by: A.M | last post by:
Hi, Can I configure a TextBox to have focus and cursor on it when page gets loaded? Thanks, Alan
4
3792
by: Christian Ista | last post by:
Hello, I have 2 questions : 1. On an ASP.NET page I have several controls (5 TextBox, 1 Dropdown and 1 button) Only the dropdown is AutoPostBack = true, the TextBox are SingleLine When I execute the page, I fill in the textbox, I change the dropdown selection, the page is reloaded no problem I see the textbox still fill in.
12
4910
by: CLEAR-RCIC | last post by:
Hi, I'm having problems setting focus to a textbox on a web user contol on an asp.net web page. The following script works on normal asp.net pages: <script language="javascript"> function cmdButton1_Clicked() { document.all('txtInput1').focus(); return false; }
11
7359
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz 1.7.12 (linux kubuntu). It does work with konqueror. It seems to work with firefox on windows but not with IE (not completly sure though).
3
2150
by: DJTN | last post by:
I have an IE web control on a form that rotates the stats of the call center in it. When a new page is loaded it takes the focus away from the other textboxes on the form, even if a user is typing in them. Is there anyway to keep the control from getting focus?
8
2264
by: zacware | last post by:
I have an AJAX enabled page which contains a list of records out of a database which are loaded into a div via an AJAX call. If the user switches to another window, and comes back to this open window later on, I want the list of records to be udpated when the window is back in front a simple onFocus doesn't work, as what happens is that if a button is clicked on the window it causes the onfocus to fire as well
4
6056
by: pablorp80 | last post by:
Hello, Here is what I need: I need the focus and the cursor set to a textbox named txtGT, every time no matter if it is the first page load or whether it is a postback. Here is the problem: I am using AJAX and MasterPages as well as an update panel, the textbox is in a panel. I have tried to do it using different java scripts but I can't get it to work because I am not using asp forms, instead I am using Containers. Here is my code:...
8
6905
by: Mel | last post by:
I have several text boxes and drop-down lists in an AJAX Update Panel. All user inputs have the Postback property set to True. After I type something in the first input entry and press the "Tab" key how can I set the focus to the next box after the postback? Please help! Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
0
10593
Oralloy
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...
0
10340
jinu1996
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...
1
7626
isladogs
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...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
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
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.