Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Inserting information

  1. #1
    Jaan Guest

    Inserting information

    Well.. i have this little problem.. I have one page where.. there's one input.. and then i have to click on one link.. and it opens one popup window.. there i have to select something.. and when i click "use" in this popup window.. it closes this popup window and it inserts this information into input..

    maybe someone knows how to do it..

  2. CODECALL Circuit advertisement

     
  3. #2
    Jordan Guest

    Re: Inserting information

    When you click the link execute HTTP Request that connects to a PHP script and submits the data. On return (when your PHP script finishes) close the window using JavaScript.

  4. #3
    Jaan Guest

    Re: Inserting information

    umm..can you give me a little example? because i'm not good with ajax yet

  5. #4
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Inserting information

    HTML Code:
    <a href="#" onClick="close()">Close</a>
    Code:
    var xmlHttp
    
    function GetXmlHttpObject()
    {
        var xmlHttp = null;
    
        try {
            xmlHttp = new XMLHttpRequest();
        } catch (e) {
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
    
        return xmlHttp;
    }
    
    function close()
    {
        xmlHttp = GetXmlHttpObject();
    
        if (xmlHttp == null) {
             alert ("Your browser does not support AJAX!");
            return;
        }
    
        var url_update = "file.php";
        url_update = url_update + "?var1=" + document.FORM_NAME.INPUT_NAME1.value;
        url_update = url_update + "&var2=" + document.FORM_NAME.INPUT_NAME2.value; 
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                window.close();
            }
        }
    
        xmlHttp.open("GET", url_update, true);
        xmlHttp.send(null);
    
    
    }
    Code:
    mysql_query("INSERT INTO `db` (`var1`, `var2`) VALUES($_GET['var1'], $_GET['var2'])"); 
    untested...
    Last edited by John; 07-14-2008 at 01:55 PM.

  6. #5
    Jaan Guest

    Re: Inserting information

    wait.. what it should do?

  7. #6
    tecktalk is offline Programmer
    Join Date
    May 2008
    Posts
    179
    Rep Power
    0

    Re: Inserting information

    hmmm yes it can be done by here....
    _________________________
    fodbold spil Desktop sharing and PowerPoint sharing with video conferencing

  8. #7
    wahkiz is offline Learning Programmer
    Join Date
    Jul 2008
    Posts
    30
    Rep Power
    13

    Re: Inserting information

    Code:
    var url_update = "file.php";
        url_update = url_update + "?var1=" + document.FORM_NAME.INPUT_NAME1.value;
        url_update = url_update + "&var2=" + document.FORM_NAME.INPUT_NAME2.value;
    Basically sends two GET input to file.php. So if your Form's input_name1 textbox is A and input_name2 textbox is B. It requests the server via Ajax "file.php?var1=A&var2=B"

    Code:
    <?
    mysql_query("INSERT INTO `db` (`var1`, `var2`) VALUES($_GET['var1'], $_GET['var2'])");
    ?>
    This belongs to the file.php. Asks mysql to save the two variables into the database. Obviously won't work tho, you are lacking mysql_connect and mysql_select_db.

  9. #8
    MrGamma is offline Learning Programmer
    Join Date
    Jul 2008
    Posts
    50
    Rep Power
    13

    Re: Inserting information

    You could try this...

    Code:
    var newframe = document.createElement("IFRAME");
    document.body.appendChild(newframe);
    newframe.location.replace('http://mydomain.com/mypage.html');
    The contents of the iframe could call a function with an onlcick event handler...
    HTML Code:
    <a href="#" onclick="top.newframe.style.display = 'none';">Click Me></a>
    Last edited by Jaan; 07-30-2008 at 05:46 AM. Reason: Use tags when you're posting your codes..

  10. #9
    Jaan Guest

    Re: Inserting information

    hmm.. I'm not stupid but i still can't get it.. I believe if I don't understand it now then I don't need it now.. so this means I have to use another way.. :/

  11. #10
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: Inserting information

    hmm.. maybe noone have really understood your question?

    I have a guess how you mean:

    you have an ordinary text input that you want to fill with a value, either you can write the value, or, you want ppl to be able to seach for them, so if they want to search, they klick an adjacent button and gets a new popup window with a search function.
    when they have fount the hot they want, they choose it by clicking a button in this popup button, which closes the popup and enters the correct value into the base page input?

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. HELP in inserting records in a table
    By sydneytot in forum PHP Development
    Replies: 3
    Last Post: 09-24-2011, 07:35 PM
  2. error in inserting record
    By ravi951 in forum PHP Development
    Replies: 5
    Last Post: 08-21-2011, 11:56 AM
  3. inserting and deleting using php
    By ravi951 in forum PHP Development
    Replies: 3
    Last Post: 08-19-2011, 03:54 AM
  4. inserting and deleting in php
    By ravi951 in forum PHP Development
    Replies: 2
    Last Post: 08-17-2011, 08:57 PM
  5. Inserting info..
    By Jaan in forum PHP Development
    Replies: 5
    Last Post: 10-19-2008, 01:34 PM

Tags for this Thread

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