SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Zealot shoorace's Avatar
    Join Date
    Jun 2005
    Location
    Florida
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Ajax generated form fields value not posted in Firefox browser

    Dynamically AJAX generated form fields value are posted successfully in IE browser but the same thing not working in Firefox browser.

    I checked printing $_POST array ie <? print_r($_POST); ?>. Those Ajax generated form fields are displayed as $_POST array index while using IE browser but the same fields are displayed as $_POST array index.

    Please give me solution fast...its urgent

  2. #2
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which Ajax package do you use?
    Post your form code!

  3. #3
    SitePoint Zealot shoorace's Avatar
    Join Date
    Jun 2005
    Location
    Florida
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basic code associated with this part is

    <script>
    var XMLHttpRequestObject = false;
    if (window.XMLHttpRequest){
    XMLHttpRequestObject = new XMLHttpRequest();
    }else if(window.ActiveXObject){
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }

    function getSystemSubClassAjax(whereto, divID, controlID){
    if (XMLHttpRequestObject){
    show_loading();
    var obj = document.getElementById(divID);
    var variables = "systemid=" + controlID.value;
    XMLHttpRequestObject.open("POST", whereto, true);
    XMLHttpRequestObject.setRequestHeader("Content-type","application/x-www-form-urlencoded")
    XMLHttpRequestObject.onreadystatechange = function()
    {
    if (XMLHttpRequestObject.readyState == 1){
    }
    else if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200){
    obj.innerHTML = XMLHttpRequestObject.responseText;
    hide_loading();
    }
    }
    XMLHttpRequestObject.send(variables);
    }
    }
    </script>

  4. #4
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see where you assign your variables
    XMLHttpRequestObject.send(variables);

  5. #5
    SitePoint Zealot Servyces's Avatar
    Join Date
    Jun 2007
    Location
    The Netherlands
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by REMIYA View Post
    I don't see where you assign your variables

    He does that with this code:

    var variables = "systemid=" + controlID.value;
    Last edited by Servyces; Jun 13, 2007 at 09:40.
    Servyces.com
    Where itís all about you.
    Your partner in online solutions.
    Visit our website at http://www.servyces.com/

  6. #6
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by shoorace View Post
    Dynamically AJAX generated form fields value are posted successfully in IE browser but the same thing not working in Firefox browser.
    Where are the dynamically generated form fields values, and how do you extract them from your form!

  7. #7
    SitePoint Zealot shoorace's Avatar
    Join Date
    Jun 2005
    Location
    Florida
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dynamically generated form fields:

    <select name="systemid" class="box_blue" onChange="getSystemSubClassAjax('../includes/medicine_process.php','divDisplayChoice',this)">
    <option>System</option>
    <?php
    while ($systemdata = mysql_fetch_array($SystemName)){
    echo '<option value="' . $systemdata['system_id'] . '">' . $systemdata['system_name'] . '</option>';
    }
    </select>
    <div id="divDisplayChoice" align="left"></div>

  8. #8
    SitePoint Zealot shoorace's Avatar
    Join Date
    Jun 2005
    Location
    Florida
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dynamically generated form fields:

    <select name="systemid" class="box_blue" onChange="getSystemSubClassAjax('../includes/medicine_process.php','divDisplayChoice',this)">
    <option>System</option>
    <?php
    while ($systemdata = mysql_fetch_array($SystemName)){
    echo '<option value="' . $systemdata['system_id'] . '">' . $systemdata['system_name'] . '</option>';
    }
    ?>
    </select>
    <div id="divDisplayChoice" align="left"></div>

  9. #9
    SitePoint Zealot shoorace's Avatar
    Join Date
    Jun 2005
    Location
    Florida
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?
    //medicine_process.php
    session_start();
    require_once("../includes/clsDbconn.php");
    require_once("../includes/clsSystem.php");
    $objDbconn = new Dbconn();
    $objSystem = new System();

    $result = $objSystem -> getSystemSubClassByidAjax($_POST["systemid"]);
    if($result){
    $display = "";
    while($row = mysql_fetch_assoc($result)){
    $display .= "<div><input type='checkbox' name='chkSystemId[]' value='" . $row['system_id'] . "' />" . $row['system_name'] . "</div>";
    }
    echo $display;
    }else{
    echo "No data found";
    }
    ?>

  10. #10
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now I see where the real problem is.

    This code is not cross browser, but works in IE only:
    controlID.value
    Here is the cross-browser solution for you:
    controlID.options[controlID.selectedIndex].value;
    Hope that helps

  11. #11
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you taken a look at jquery. It's a free cross browser java script library that will make your ajax/javascript life MUCH easier and reduce code size considerably.

    I have used it for a couple of projects, and LOVE it.

    (No affiliation with them other than being a fan).

    -JasonR


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
  •