473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Moving view to start of text field

I'm having trouble with some javascript functionality.

I have a text input that can hold more characters than it can show. When the focus leaves the text field I have to show the start of the string again, instead of the end that they just typed in. I've been able to get this functionality to work in firefox, but not IE. The only thing I found that almost worked was using ranges and selecting elements 0 to 0. However, I'm doing this function in an onBlur action, so this will never leave the text box

Any ideas on how to view the start of a start of a string in a text field in an onBlur action?
Sep 10 '07 #1
5 1290
gits
5,390 Expert Mod 4TB
hi ...

welcome to TSDN ...

have a look at the following example ... may be it helps :)

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function do_blur(obj) {
  3.     obj.value = obj.value;
  4. }
  5. </script>
  6.  
  7. <input type="text" name="test" onblur="do_blur(this);"/>
  8.  
kind regards
Sep 10 '07 #2
iam_clint
1,208 Expert 1GB
This is a piece of sample code i made for ya give it a go (works in firefox and IE)
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script>
  3. var oldval = "";
  4. var objid;
  5. function moveStart(obj) {
  6.         oldval = obj.value;
  7.         obj.value = "";
  8.         objid = obj.id
  9.         window.setTimeout("resetVal();", 10);
  10. }
  11. function resetVal() {
  12.     document.getElementById(objid).value = oldval;
  13. }
  14. </script>
  15. <body>
  16. <input type="text" id="test" onblur="moveStart(this);">
  17. <input type="text" id="test1" onblur="moveStart(this);">
  18. <input type="text" id="test2" onblur="moveStart(this);">
  19. <input type="text" id="test3" onblur="moveStart(this);">
  20. </body>
  21. </html>
  22.  
Gits your version didn't work in IE for me because there was no delay between resetting the value.
Sep 10 '07 #3
gits
5,390 Expert Mod 4TB
heya iam_clint,

well ... you are certainly right ;) ... since i have no IE at home i cannot test it ... but the simple idea was to assign the same value to the field as the one thats actually typed in there ... and to avoid that selection and range operations which seems to be really obsolete here :) ... thank you for proofing and improving the idea ...

kind regards
Sep 10 '07 #4
Ah, thank you. The first post is what I was doing in firefox, and I figured that it wasn't working in IE because it was the same value... for some reason I didn't think to clear it out first. Not at my development computer right now, but I'm sure it will work. Thanks again!
Sep 11 '07 #5
gits
5,390 Expert Mod 4TB
hi ...

no problem ... we are glad to help you ...post back to the forum anytime you have more questions ...

kind regards
Sep 12 '07 #6

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

Similar topics

4
by: ghanley | last post by:
Hi Guys, I need some help with a problem related to the looping through a recordset to display on a tree view control. My table has no Primary key - because duplicates are allowed. ID ...
2
by: Ted | last post by:
Hello all. Its been a few years since I've been here. I hope everyone is well. I am working on a report that has several sub reports in the detail section. I have sized the sub reports to have...
3
by: aljodo | last post by:
ASP.Net v1.1 & vb.net Hi all, I have a simple survey form with first name/last name text boxes at the top. I have validators on these text boxes to ensure that something is entered in them. ...
6
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox...
3
by: Mark | last post by:
Is there a way to just move the field values and not the field descriptions within a form in design view? I try to grab just those values and it takes the descriptions with it. Some field names are...
6
by: Bill44077 | last post by:
Hi, I am new to the MVP pattern and one of the main reasons that we are going this route is because we are doing Scrum with 30 day sprints - so we have a continually morphing design. We are...
1
by: Parasyke | last post by:
Thanks in advance... I need to on a subform in datasheet view to be able to, instead of delete a record, move that record to another table. I can if needed turn the subform into a continuous form...
0
by: mtsylvester | last post by:
Hi All, How do I add a List Box to a dynamic Details View. I want to replace the check boxes with list boxes. If I try to simply replace the check box with a list box it complains about not being...
0
by: jvitti | last post by:
I recently upgraded from Access 2000 to Access 2007 and I am having trouble with moving the focus from 1 form to another. While doing data entry if a similar claim is found the claim view form...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.