SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    0 Post(s)
    0 Thread(s)

    SOLVED - form output ajax dynamic function.


    Just a note to inform you that this is now solved.

    In the last input box I now got onblur="myfunction(,'r1c2','r1c4'), this allows me to get the content of both input boxes, and also gives me the correct outputbox.
    r1c2 is the id name of the previous inputbox and r1c4 is the id name of the outpub box, r1 is row1, c2 and c4 is the column number. That way I can easily know what goes where.
    The javascript functions is taking these parameters - myfunction(param1,param2,param3) and then the getelementbyid(param1).value and so on.
    I then send the r1c4 param along to the php script and using it as a variable in the xml feedback so that the output gets in the right boxs.

    Original post follows:

    Since this is my first post, I guess it's time for the "newbee" warning. (To ajax that is).

    I've got a table with 10 rows and 4 columns. Each containing an <input> element of my form. The input box in row 1, column 1 is used for "number of items", the next input box (row 1, column 2) is for "product numer" and the third input box (row 1, column 3) is for another id number. The last input box, row 1 column 4, is used to display the name of the product and the name assigned to the last id number.

    This is then duplicated for the next 9 rows.

    I've got unique id's on every input, based on what row it's on and what input it gives me. And the input box in column 3 has this : onblur="getproductinfo(;" This enables me to know what input box sent the reqest like this :

    function getproductinfo(pid) {
    var idvalue = document.getElementById(pid).value;

    By now I've got the code to make this request and serve back (in xml format, see below) the output. But it's not in a dynamic way that I need it to be.

    Now I use this to fill out the row1 column4 text field :
    var pidn = xmlDocument.getElementsByTagName('pidn').item(0);
    document.getElementById('r1c4text').value = pidn;

    Which it gets from the php file getting the result from the mysql table and returning it like this :
    $return_value = '<?xml version="1.0" encoding="iso-8859-1" ?><pidn>'.$psted.'</pidn>';

    I use this to call the external php :
    var reqest = document.getElementById(vpid).value;"GET", url + escape(request), true);

    So, my question :

    Let's say the user fills out row 1 like this : 1, 10001, 20002.
    I then need my script to take the last two numbers, take number one and return the proper product name and number two and return the proper name for the id number (this is from two different tables). The output for this is supposed to go into row 1 column 4. And the same for the next 9 rows (example: take the numbers from row 5 and put the result into row 5 column 4)

    Does anyone know how I could get back my data in such a dynamic way? And how to send both id numbers.

    This is the last bit of my system so it would be nice to just have this to work.

    Thank you for your time reading my post.
    Last edited by d4rg0; Dec 9, 2006 at 10:23. Reason: solved


Posting Permissions

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