SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 48 of 48
  1. #26
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I have further extended your code so that I can submit the form as below.The fortunate part now when I post it is ok in both firefox and IE. Immediately below is also my fully getMaster function can see both are identical.

    <?php
    session_start();


    if($_POST['submit'])
    {
    echo "Master ID:".$_POST['masterID'];
    }
    ?>
    <html>

    <body>
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="form1" id=form1 >
    <table id="myTable">
    <tr id="row0"></tr>
    <tr id="row1"></tr>
    <!-- script adds row two here -->
    </table>
    <input class="buttons" type="Submit" name="submit" value="submit" >
    </form>
    <script>
    var xmlhttp =
    {
    responseText: '<input type=text name=masterID id=masterID value=4>'
    };
    var x=document.getElementById('myTable').insertRow(2);
    var y=x.insertCell(0);
    var z=x.insertCell(1);
    var newdiv = document.createElement("div");
    newdiv.innerHTML = xmlhttp.responseText;
    y.innerHTML="<label class=description for=element_1>Master <font color='red'>*</font></label> ";
    while (newdiv.hasChildNodes())
    { z.appendChild(newdiv.firstChild);
    }
    </script>

    </body>

    </html>
    My getMaster.

    function getMaster(entID,nextElement,str)
    {
    var table = document.getElementById('myTable');
    var rowCount = table.rows.length;
    //alert("Row count : "+rowCount);

    if(rowCount>2)
    {
    for(var i=2; i<rowCount; i++)
    {
    var row = table.rows[i];

    table.deleteRow(i);
    rowCount--;
    i--;
    }
    }

    differentiator=Math.floor(Math.random()*50000);
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    var x=document.getElementById('myTable').insertRow(2);
    var y=x.insertCell(0);
    var z=x.insertCell(1);
    var newdiv = document.createElement("div");
    newdiv.innerHTML = xmlhttp.responseText;
    y.innerHTML="<label class=description for=element_1>Master <font color='red'>*</font></label> ";
    while (newdiv.hasChildNodes())
    { z.appendChild(newdiv.firstChild);

    }

    var a=document.getElementById('myTable').insertRow(3);
    var b=a.insertCell(0);
    var c=a.insertCell(1);
    b.innerHTML="";
    c.innerHTML="<p class=error id='masterIDError'>";

    if(nextElement=="trailer")
    {
    getTrailer(entID);
    }
    else
    {
    getSlaves(entID,str);
    }
    }

    }
    xmlhttp.open("GET","getMasterList.php?e="+entID+"&d="+differentiator,true);
    xmlhttp.send();


    }

  2. #27
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Linuxfreelancer,
    I dont quite get you why you need this.

    XMLHttp.onreadystatechange = function ()
    {
    if (XMLHttp.readyState == 4)
    {
    document.getElementById("myTable").innerHTML = XMLHttp.responseText;
    }
    };

  3. #28
    SitePoint Zealot LinuxFreelancer's Avatar
    Join Date
    Jun 2011
    Location
    Boston, Ma, Usa
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Linuxfreelancer,
    I dont quite get you why you need this.
    After posting the form, this returns the value returned by the parsing php script. So the form can be in the div and after submission, the form is replaced by a message like "thank you for submitting" or whatever you want to show there.

    I use something like this on a social networking script's "facebook like wall". After submitting, the div contents are updated with the new status message posted, just like on facebook. I hope this makes sense.

  4. #29
    SitePoint Zealot LinuxFreelancer's Avatar
    Join Date
    Jun 2011
    Location
    Boston, Ma, Usa
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why are you doing this?

    <?=$_SERVER['PHP_SELF']?>

    That is kind of a waste of resources. Just put the script name or even "#".

    Also, start using full tags because your scripts will break soon if you use shorthand, should be:

    <?PHP $_SERVER['PHP_SELF']?>

  5. #30
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I hate to ask, for fear of ruining the hard work you've done so far, but is there a reason you're not using a JavaScript library? It makes this sort of stuff much more concise/manageable.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #31
    SitePoint Zealot LinuxFreelancer's Avatar
    Join Date
    Jun 2011
    Location
    Boston, Ma, Usa
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I kind of like custom myself... most of the time, custom lets you tighten up the code better without any filler you don't need. That's just my 2 cents.

  7. #32
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear LinuxFreeLancer,
    I just put like this. Again in IE the alert appear but not in Firefox. So what could be thins problem?
    var VariableOne = encodeURIComponent(document.forms["form1"].elements["masterID"].value);
    alert("MAster ID:"+VariableOne);

  8. #33
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Anthony,
    I do not of any specific library which could do my task exactly?

  9. #34
    SitePoint Zealot LinuxFreelancer's Avatar
    Join Date
    Jun 2011
    Location
    Boston, Ma, Usa
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need to see the full code, can you pass me the url, that is even better.

  10. #35
    SitePoint Enthusiast
    Join Date
    Feb 2011
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use post tag nd new div="" change the attributes

  11. #36
    SitePoint Zealot LinuxFreelancer's Avatar
    Join Date
    Jun 2011
    Location
    Boston, Ma, Usa
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jargonbust View Post
    use post tag nd new div="" change the attributes
    Please use complete sentences so it makes sense, we are not in your mind so shorthand isn't so good in this instance.

  12. #37
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Anthony,
    I do not of any specific library which could do my task exactly?
    Here's a very simple jQuery implementation to make a POST request to the server, then append the result to a HTML table.

    Code HTML4Strict:
    <?php
    if('POST' === $_SERVER['REQUEST_METHOD']){
      echo 'The server says the time is ' . date('r') ;
      exit;
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" media="screen" href="http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css" />
        <link rel="stylesheet" type="text/css" media="screen" href="http://yui.yahooapis.com/3.3.0/build/cssbase/base-min.css" />
        <link rel="stylesheet" type="text/css" media="screen" href="http://yui.yahooapis.com/3.3.0/build/cssfonts/fonts-min.css" />
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
        <title>
          Sitepoint.com Demo
        </title>
        <style type="text/css">
          #request{
            padding: 5px;
            margin: 5px;
            border: solid 1px #ccc;
            text-decoration: none;
          }
          #request:hover{
            background-color: #eee;
          }
        </style>
      </head>
      <body>
        <table id="results">
          <thead>
            <tr>
              <th>Request #</th>
              <th>Response</th>
            </tr>
          </thead>
          <tbody>
          </tbody>
        </table>
        <a id="request" href="#">Request Server Time</a>
    		<script type="text/javascript">
    			$(document).ready(function(){
            $('#request').click(function(){
              $.post('index.php', function(time){
                var requestNumber = $('#results tbody tr').length + 1;
                $('#results tbody').append('<tr><td>' + requestNumber + '</td><td>' + time + '</td></tr>');
              })
            });
    			});
    		</script>
      </body>
    </html>

    The URL for this is here, so you can see it live.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  13. #38
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear LinuxFreelancer,
    Here is my link http://183.78.169.53/scv/a2.php. You can just fill a text value into the A1 input box. Then just select the vehicle drop down list and will see a master list. Just pick any master list and submit the form. You will notice the masterID does not appear when I capture the post values.

  14. #39
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Woah, that's pretty JS heavy. Have you managed to look at any of the JS libraries yet?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  15. #40
    SitePoint Zealot LinuxFreelancer's Avatar
    Join Date
    Jun 2011
    Location
    Boston, Ma, Usa
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear LinuxFreelancer,
    Here is my link http://183.78.169.53/scv/a2.php. You can just fill a text value into the A1 input box. Then just select the vehicle drop down list and will see a master list. Just pick any master list and submit the form. You will notice the masterID does not appear when I capture the post values.
    Asset : TestngA1masterID : 4

    I got that after I submitted, TestngA1 was my A1 text, looks like it posts fine.... unless I am missing something?

  16. #41
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear LinuxFreelancser,
    Dont try on IE it works for me. Try on firefox or chrome. Then do let me know ya.

  17. #42
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Anthony,
    Actually I tried to work on Jquery but my knowledge is very shallow in it. That is why I opt for this. IF you have any good relevant site for my problem do let me know ya.

  18. #43
    SitePoint Zealot LinuxFreelancer's Avatar
    Join Date
    Jun 2011
    Location
    Boston, Ma, Usa
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah in FF4 I only got a partial response:

    Asset : bbbbbbmasterID :

  19. #44
    SitePoint Zealot LinuxFreelancer's Avatar
    Join Date
    Jun 2011
    Location
    Boston, Ma, Usa
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not just do in pure php like this?
    MobileBlueBook.com - Free Value Estimates on Mobile Devices

  20. #45
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear linuxfreelancer,
    This is my biggest problem why firefox not able to capture the values?

  21. #46
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear All,
    Just to add further on what I did is that onChange of my master drop list I have this function.
    function setMasterID(masterID)
    {
    alert("MAsterID : "+masterID);
    document.form1.hiddenMasterID.value = masterID;
    }
    Then first I tried like this below where I add this y.innerHTML="<label class=description for=element_1>Master <font color='red'>*</font></label><input type=hidden value='' name=hiddenMasterID> "; So when I submit no value is capture for hiddenMasterID.

    function getSlaveTrailer(str)
    {
    differentiator=Math.floor(Math.random()*50000);
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    var x=document.getElementById('myTable').insertRow(2);
    var y=x.insertCell(0);
    var z=x.insertCell(1);
    var newdiv = document.createElement("div");
    newdiv.innerHTML = xmlhttp.responseText;
    y.innerHTML="<label class=description for=element_1>Master <font color='red'>*</font></label><input type=hidden value='' name=hiddenMasterID> "; while (newdiv.hasChildNodes())
    { z.appendChild(newdiv.firstChild);
    }
    }
    }
    xmlhttp.open("GET","getMasterList.php?e=1&d="+differentiator,true);
    xmlhttp.send();
    }
    Then secondly I tried to move like below. So I added this <input type=hidden value="" name=hiddenMasterID>. What I would like to know why in the earlier method when I built the hidden itself it does not work. But when I put in the table id="tblSubmit" it works fine. What is blocking from the value being captured?

    <table id="tblSubmit">
    <tr>
    <td>
    <input type=hidden value=<?php echo $editVal?> name=editVal>
    <input type=hidden value="" name=hiddenMasterID>
    <input class="buttons" type="Submit" name="<?php echo $submitTag?>" value="<?php echo $submitTag?>" onClick="return validateForm();">
    </td>
    <td>
    <input class="buttons" type="Reset" name="Reset" value="Reset" onclick="location.href='addVehicle.php'">
    </td>
    </tr>
    </table>
    <table id="tblSubmit">
    <tr>
    <td>
    <input type=hidden value=<?php echo $editVal?> name=editVal>
    <input type=hidden value="" name=hiddenMasterID>
    <input class="buttons" type="Submit" name="<?php echo $submitTag?>" value="<?php echo $submitTag?>" onClick="return validateForm();">
    </td>
    <td>
    <input class="buttons" type="Reset" name="Reset" value="Reset" onclick="location.href='addVehicle.php'">
    </td>
    </tr>
    </table>

  22. #47
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Sadly there are multiple things wrong (invalid markup, broken JS, application flow ... ) with your implementation of this behaviour. My suggestion would be to start smaller and gradually add functionality until you succeed or find an issue.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  23. #48
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Anthony,
    Can you point to me the very crucial error? I have been looking into the codes for days and could not figure out what and where is the problem?


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
  •