SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Very Strange undefined ID issue

    Hello,

    today i am facing a strange problem that i never face before.

    form.php
    Code:
    <td><div id="test"><? echo $project;?></div></td>
    ajax.js
    Code:
    var test=document.getElementById("test").value;
    alert(test);
    out put is 'undefined'

    form.php
    Code:
    <td><input id="test" name="" type="text" value="<? echo $project;?>" /></td>
    ajax.js
    Code:
    var test=document.getElementById("test").value;
    alert(test);
    out put is 'G4' which works!!

    So why it is not working when i put the php value inside a div? i also tried a label. that also not working. coz i do not want to use a text box here.

    Last edited by afridy; Jan 5, 2014 at 02:36. Reason: small mistake


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
  •