Results 1 to 6 of 6

Thread: Simple onblur event script

  1. #1
    Join Date
    Feb 2013
    Location
    California
    Posts
    53
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Simple onblur event script

    I preface this post by stating that I know almost absolutely nothing about javascript.

    I am in need of a simple javascript for the onblur event of a text box that will pass the value of the text box to the php script that contains the text box.

    Maybe there is another way... This is what I need to do.

    I have a module form that consists of multiple input boxes used to enter/edit records of a database table. Also included in the module is key information from a list of selected records. At present the user scrolls through the list of records and selects one from the list. Upon selection the page reloads with the information loaded into the input boxes for editing.

    I would like to add a feature that allows the user to enter a record ID in an input box and then when the onblur event fires reload the page with the information of the entered record.

    TIA

    jdadwilson

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    < [element] onblur="myfunction(this.value);">

    Now you just need to define myfunction() to send the information to PHP.

    Code:
    function myfunction(t) {
       ajaxSend(t,'http://.....page.php');
    }
    Then you'll need to define ajaxSend() using any number of possible ajax scripts. You could send the value as POST, GET, etc.

    Does that generally make sense? Any tutorial on Ajax should give you the rest of the info you need.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2013
    Location
    California
    Posts
    53
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    < [element] onblur="myfunction(this.value);">

    Now you just need to define myfunction() to send the information to PHP.

    Code:
    function myfunction(t) {
       ajaxSend(t,'http://.....page.php');
    }
    Then you'll need to define ajaxSend() using any number of possible ajax scripts. You could send the value as POST, GET, etc.

    Does that generally make sense? Any tutorial on Ajax should give you the rest of the info you need.

    I guess I am now more confused... If I am using PHP why should I call an ajax script?

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Javascript cannot interact directly with PHP. That's what AJAX is for. You should read a tutorial about AJAX and come back with more specific questions. (I don't mean to sound dismissive, but you need to understand the basics of how this works.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Feb 2013
    Location
    California
    Posts
    53
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    Javascript cannot interact directly with PHP. That's what AJAX is for. You should read a tutorial about AJAX and come back with more specific questions. (I don't mean to sound dismissive, but you need to understand the basics of how this works.)
    Thanks for the info. Don't worry about sounding dismissive. Although I am old, I still need to learn new tricks. Thanks...

    jdadwilson

  6. #6
    Join Date
    Feb 2013
    Location
    California
    Posts
    53
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jdadwilson View Post
    Thanks for the info. Don't worry about sounding dismissive. Although I am old, I still need to learn new tricks. Thanks...

    jdadwilson
    OK, I am starting to get my brain around the issue. Sorry for any misunderstanding.

    What I need to do is simply send a parameter (the text in the input onblur box) back to the script containing the onblur input box. Something similar to:

    Code:
    <input onblur="enterID('<?php $_SERVER['SCRIPT_NAME'] . "?load="?>this.value');" />
    This works for selecting a table row with an onclick event since the value passed is preset and not dependent on this.value.

    Code:
    <tr onclick="selectRow('myScript.php?mov=11');">
    This is the function...

    Code:
    function selectRow(theUrl) { document.location.href = theUrl; }
    In this case the mov number is set when the table is built, not at runtime as needed for the onblur.

    The event is firing and my code is processing the request, it is just that the $_GET value is 'this.value' not the actual value.

    Again, TIA for your assistance

    jdadwilson

Similar Threads

  1. Adding an onblur event to a selectbox div only mockup
    By jason_kelly in forum JavaScript
    Replies: 5
    Last Post: 11-24-2013, 07:33 PM
  2. what to use in the field onblur, onload, onchange...???
    By leonidassavvides in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 10-31-2008, 07:33 PM
  3. help with onBlur not working
    By bvaroni in forum JavaScript
    Replies: 0
    Last Post: 05-09-2008, 09:31 PM
  4. Replies: 1
    Last Post: 02-25-2008, 08:44 PM
  5. JavaScript and DOM textarea onblur issue.?
    By dekemcaffee in forum JavaScript
    Replies: 1
    Last Post: 09-10-2007, 09:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •