• We just launched and are currently in beta. Join us as we build and grow the community.

Load Data From Database Via ComboBox and Display in Input Box

GayCummer

Dark Web Explorer
G Rep
0
0
0
Rep
0
G Vouches
0
0
0
Vouches
0
Posts
118
Likes
169
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
This is a simple application for beginners that loads data from database via combo-box and displays respective data in input box.

Sample code:
  1. <

    html>
  2. <

    head>
  3. <

    script>
  4. function

    showgrains(

    str)
  5. {
  6. if

    (

    str==

    ""

    )
  7. {
  8. document.

    getElementById(

    "txtHint"

    )

    .

    innerHTML=

    ""

    ;

    //txtHint is an event handler
  9. return

    ;
  10. }
  11. if

    (

    window.

    XMLHttpRequest)

    //XMLHttp request object is created and we are checking whether ajax works in diffrent browsers..i.e we are checking browser compatibity
  12. {

    // code for IE7+, Firefox, Chrome, Opera, Safari
  13. xmlhttp=

    new

    XMLHttpRequest(

    )

    ;
  14. }
  15. else
  16. {

    // code for IE6, IE5
  17. xmlhttp=

    new

    ActiveXObject(

    "Microsoft.XMLHTTP"

    )

    ;
  18. }
  19. xmlhttp.

    onreadystatechange=

    function

    (

    )

    //xmlhttprequest object is configured
  20. {
  21. if

    (

    xmlhttp.

    readyState==

    4

    &&

    xmlhttp.

    status==

    200

    )

    //asyncronous request to web server
  22. {
  23. document.

    getElementById(

    "txtHint"

    )

    .

    innerHTML=

    xmlhttp.

    responseText;
  24. }
  25. }
  26. xmlhttp.

    open(

    "GET"

    ,

    "getgrainsinfo.php?q="

    +

    str,

    true

    )

    ;
  27. xmlhttp.

    send(

    )

    ;
  28. }
  29. </script>
  30. </

    head>
  31. <

    body>

  32. <

    form>
  33. <

    select name=

    "grains"

    onChange=

    "showgrains(this.value)"

    >
  34. <

    option value=

    ""

    >

    Select a grain:</

    option>
  35. <

    option value=

    "cotton"

    >

    cotton</

    option>
  36. <

    option value=

    "cumin"

    >

    cumin</

    option>
  37. <

    option value=

    "flowers"

    >

    flowers</

    option>
  38. <

    option value=

    "turmeric"

    >

    turmeric</

    option>
  39. <

    option value=

    "cashewnut"

    >

    cashewnut</

    option>
  40. </

    select>
  41. </

    form>
  42. <

    br>
  43. <

    div id=

    "txtHint"

    ><

    b>

    grains info will be listed here.</

    b></

    div>


  44. </

    body>
  45. </

    html>

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.

2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Download
You must upgrade your account or reply in the thread to view hidden text.
 

442,401

317,942

317,951

Top