automatic appear

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • azura
    New Member
    • Jul 2008
    • 47

    automatic appear

    Code:
    <input name="matric" type="text" class="style26" id="matric" value="<?php echo $row_rs_mas['matric_no']; ?>" size="15" />
    <------ this input that i insert those matric_no

    Code:
    <input name="name" type="text" class="style26" id="name" value="<?php echo $row_rs_mas['name']; ?>" size="50"/>
    <------ appear automatic when I insert the matric_no..

    my problem is how to make it automatically appear when insert matric_no
  • maminx
    New Member
    • Jul 2008
    • 77

    #2
    where do you want to appear that value???is it in input or what type of tag??

    if you want to appear the value of matric_no (input), than you can use the div or something tag to store that value...

    Comment

    • azura
      New Member
      • Jul 2008
      • 47

      #3
      yup.. i want to appear dynamically value in that input"name"..li ke this.. if i key in matric no, then dynamically appear those name... those name n matric are in database

      Comment

      • maminx
        New Member
        • Jul 2008
        • 77

        #4
        Originally posted by azura
        yup.. i want to appear dynamically value in that input"name"..li ke this.. if i key in matric no, then dynamically appear those name... those name n matric are in database

        i see, so you want to appear the name that you input from textfield and get + check the name whether it is in the database or not,, i think you must use AJAX, and you just need to learn that things in this URL

        AJAX

        kind regards,
        mamin

        Comment

        • azura
          New Member
          • Jul 2008
          • 47

          #5
          Code:
           var url="gethint.asp";
          url=url+"?q="+str;
          url=url+"&sid="+Math.random();
          xmlHttp.onreadystatechange=stateChanged;
          xmlHttp.open("GET",url,true);
          xmlHttp.send(null);
          what this function are for??? because i had try so many time but still error..i'm new ni ajax..please help me...

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5388

            #6
            basicly it starts a XMLHttpRequest in the background to invoke the code that is found at the 'url'. you assign a callback-function to the onreadystatecha nge-property of the request-object and this function is called every time the state of the request-object changes. the code you posted is not enough ... you need the full code from an example ... post how you tried to make the call with all relevant lines ...

            kind regards

            Comment

            • azura
              New Member
              • Jul 2008
              • 47

              #7
              before this i tried to make with some button but my boss doesn't want those button... so he want to make those data dynamically appear... i'm very newbie in java n ajax.. i'm so stuck right now!

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5388

                #8
                post what you have tried so far ... may be just use a textbox and try to demonstrate your attempt and tell us where you're stuck ... so that we may help you with your particular problem ...

                kind regards

                Comment

                • azura
                  New Member
                  • Jul 2008
                  • 47

                  #9
                  [HTML]


                  <body <?php if($saved){echo 'onload="alert( \'One record successfully saved.\');"';}? >>
                  <form id="form1" name="form1" method="POST">
                  <div align="center">
                  <p>&nbsp;</p>
                  <table width="456" height="436" align="center" bordercolor="#C CFFCC" class="boxads">
                  <tr>
                  <td height="46" colspan="5" bgcolor="#FFFFC C"><p align="center" class="style16" >&nbsp;</p>
                  <p align="center" class="style16 style18">Medic Assessment System </p>
                  <p align="center" class="style16" >&nbsp;</p></td>
                  </tr>
                  <tr>
                  <td height="29" colspan="5" bgcolor="#FFFFF F" class="style12" ><div align="center" class="style10" ><span class="style17 style23">Block Registration</span></div>
                  <span class="style8">
                  <label></label>
                  </span><span class="style8">
                  <label></label>
                  </span><span class="style1"> </span><span class="style1">
                  <label></label>
                  </span>
                  <div align="center" class="style17" ></div></td>
                  </tr>
                  <tr>

                  <td width="82" height="35" bgcolor="#CCFFC C"><div align="right" class="style26" >Matric No</div></td>
                  <td width="11" bgcolor="#CCFFC C"><div align="center" class="style26" >:</div></td>
                  <td colspan="3" bgcolor="#CCFFC C"><div align="left">

                  <input name="matric" type="text" class="style26" id="matric" value="<?php echo $row_rs_mas['matric_no']; ?>" size="15" />
                  </div></td>
                  </tr>
                  <tr>
                  <td height="32" bgcolor="#CCFFC C"><div align="right" class="style26" >Name</div></td>
                  <td width="11" bgcolor="#CCFFC C"><div align="center" class="style26" >:</div></td>
                  <td colspan="3" bgcolor="#CCFFC C"><div align="left">
                  <p>
                  //this part i want to make dynamically appear
                  <input name="name" type="text" class="style26" id="name" value="<?php echo $row_rs_mas['name']; ?>" size="50"/>
                  </p>
                  </div></td>
                  </tr>
                  <tr>
                  <td height="114" bgcolor="#CCFFC C"><div align="right">< span class="style26" >Sessi</span></div></td>
                  <td bgcolor="#CCFFC C"><div align="center" class="style26" ><strong>:</strong></div></td>
                  <td bgcolor="#CCFFC C"><div align="left">
                  <input name="sessi" type="text" class="style26" id="sessi" size="15" maxlength="9" />
                  </div></td>
                  <td bgcolor="#CCFFC C"><div align="right">< span class="style26" >Year:</span></div></td>
                  <td bgcolor="#CCFFC C"><p>&nbsp;
                  </p>
                  <p>&nbsp;</p>
                  <p>
                  <select name="year" class="style26" id="year" value="<?php echo $row_scode['year']; ?>" >
                  <option value="-"> - </option>
                  <option value="1 block 1"> 1 block 1</option>
                  <option value="1 block 2"> 1 block 2</option>
                  <option value="1 block 3"> 1 block 3</option>
                  <option value="1 block 4"> 1 block 4</option>
                  <option value=" - "> - </option>
                  <option value="2 block 1"> 2 block 1</option>
                  <option value="2 block 2"> 2 block 2</option>
                  <option value="2 block 3"> 2 block 3</option>
                  <option value="2 block 4"> 2 block 4</option>
                  <option value="- "> - </option>
                  <option value="3 block 1"> 3 block 1</option>
                  <option value="3 block 2"> 3 block 2</option>
                  <option value="3 block 3"> 3 block 3</option>
                  <option value="3 block 4"> 3 block 4</option>
                  <option value=" - "> - </option>
                  <option value="4 block 1"> 4 block 1</option>
                  <option value="4 block 2"> 4 block 2</option>
                  <option value="4 block 3"> 4 block 3</option>
                  <option value="4 block 4"> 4 block 4</option>
                  <option value="4 block 5"> 4 block 5</option>
                  <option value="4 block 6"> 4 block 6</option>
                  <option value="4 block 7"> 4 block 7</option>
                  <option value=" - "> - </option>
                  <option value="5 block 1"> 5 block 1</option>
                  <option value="5 block 2"> 5 block 2</option>
                  <option value="5 block 3"> 5 block 3</option>
                  <option value="5 block 4"> 5 block 4</option>
                  <option value="5 block 5"> 5 block 5</option>
                  </select>
                  </p>
                  <p>
                  //this part i want to make dynamically appear
                  <input name="s_code" type="text" class="style26" id="s_code" value="<?php echo $row_scode['s_code']; ?>"/>
                  </p>
                  <p>&nbsp;</p></td>
                  </tr>

                  <tr>
                  <td height="27" bgcolor="#CCFFC C"><div align="right" class="style26" >Group</div></td>
                  <td bgcolor="#CCFFC C"><div align="center" class="style26" >:</div></td>
                  <td width="90" bgcolor="#CCFFC C"><div align="left">
                  <p class="style25" >
                  <select name="group" size="1" class="style26" id="group">
                  <option value="-">-</option>
                  <option value="1" >1</option>
                  <option value="2" >2</option>
                  <option value="3" >3</option>
                  <option value="4">4</option>
                  <option value="5">5</option>
                  <option value="6">6</option>
                  <option value="7">7</option>
                  <option value="8">8</option>
                  <option value="9">9</option>
                  <option value="10">10</option>
                  <option value="11">11</option>
                  <option value="12">12</option>
                  </select>
                  </p>
                  </div></td>
                  <td width="73" bgcolor="#CCFFC C"><div align="right"></div></td>
                  <td width="176" bgcolor="#CCFFC C">&nbsp;</td>
                  </tr>

                  <tr>
                  <td height="24" colspan="5" bgcolor="#CCFFC C"><div align="center">
                  <input name="save" type="submit" class="style26" id="save" value="Save" />
                  <input name="Reset" type="reset" class="style26" value="Reset" />
                  </div>
                  <div align="center"> </div></td>
                  </tr>
                  </table>

                  </html> [/HTML]
                  hurm i send my coding... there is 2 part which i want to make it dynamically appear..

                  Comment

                  • azura
                    New Member
                    • Jul 2008
                    • 47

                    #10
                    anybody can help me??

                    Comment

                    • gits
                      Recognized Expert Moderator Expert
                      • May 2007
                      • 5388

                      #11
                      so what you want is that you put in the matric_no and then the corresponding textboxes name and s_code should be populated automatically.

                      the general idea is the following:

                      1. onchange of the textbox matric_no call a js-function that starts a XMLHttpRequest and retrieves the data from the database

                      2. in the callbackfunctio n of that request you process the responseText and fill in the data into the corresponding fields ...

                      are you familiar with such an ajax-call? did you use/try that before?

                      kind regards

                      Comment

                      • azura
                        New Member
                        • Jul 2008
                        • 47

                        #12
                        yup you right! when i put matric_no textfield name will automatically appear the name so with if i select year,s_code will automatically appear...

                        i'm not familiar with ajax and that's why i need somebody help me.... urgent and really urgent....plezz zz!!!

                        Comment

                        • gits
                          Recognized Expert Moderator Expert
                          • May 2007
                          • 5388

                          #13
                          ok ... so let me give you a short example, it uses GET and requests just a local file called test.txt where you could put in any text ... when the request is ready it will put this text from the file into the second textbox ... as you see it is quite simple to use the XMLHttpRequest ... note: this example just works with browsers like FF/Safari/Opera (that have a native XMLHttpRequest-Object) since i didn't implement the request-initialisation for IE

                          [CODE=javascrip]<html>
                          <head>
                          <script type="text/javascript">
                          function _get_request_ob j() {
                          var obj = null;

                          if (typeof window.XMLHttpR equest != 'undefined') {
                          obj = new XMLHttpRequest;
                          } else if (typeof window.ActiveXO bject != 'undefined') {
                          // MS specific trunk to init a request-object
                          }

                          return obj;
                          }

                          function get_data(val, id) {
                          var obj = _get_request_ob j();

                          if (obj == null) {
                          alert('currentl y no ajax-call supported');
                          } else {
                          _request_data(o bj, val, id);
                          }
                          }

                          function _request_data(r eq, val, id) {
                          var qs = 'test.txt?val=' + val;

                          req.open('GET', qs, true);
                          req.onreadystat echange = function() {
                          if (this.readyStat e == 4) {
                          var result_box = document.getEle mentById(id);
                          result_box.valu e = this.responseTe xt;
                          }
                          };
                          req.send(null);
                          }

                          </script>
                          </head>
                          <body>
                          <form>
                          <input type="text" id="my_box_1" onchange="get_d ata(this.value, 'my_result');"/>
                          <input type="text" id="my_result"/>
                          </form>
                          </body>
                          </html>
                          [/CODE]
                          kind regards

                          Comment

                          • azura
                            New Member
                            • Jul 2008
                            • 47

                            #14
                            what if i want to implement with ff and ie?? sorry i still don't get it... if i implement your example in my line, which want should i change..?? test.txt stand for what??

                            Comment

                            • gits
                              Recognized Expert Moderator Expert
                              • May 2007
                              • 5388

                              #15
                              1. test.txt stands for the requested program ... so qs has to be your querystring (probably a php-file and some get-params in case you want to use GET) ...

                              2. for IE you have to create an instance of an ActiveX object like this (that would replace the comment in line 10):

                              [CODE=javascript]try {
                              obj = new ActiveXObject(' Msxml2.XMLHTTP' );
                              } catch (ex) {
                              try {
                              obj = new ActiveXObject(' Microsoft.XMLHT TP');
                              } catch (ex) {
                              }
                              }[/CODE]
                              note: make an attempt and show what you have done ... at this forum nobody is supposed to do your work for you or give you a complete solution ... with the currently given example you could simulate one test for your requirement ... just try to adapt it to your problem and show the code that is not working and ask specific questions ... a thread like this is not the appropriate place to give you a complete ajax-tutorial ... so you need to search for some basic information for your own ... ok?

                              kind regards

                              Comment

                              Working...