Specifying image source dynamically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daitasri
    New Member
    • Feb 2008
    • 18

    Specifying image source dynamically

    Hi,
    I am using HTML,Javascript . I m trying to specify source path for a dynamically created element.But its not displaying the image.Please help me.
    I m using the following code:


    [CODE=javascript]var row1td7=documen t.createElement ('TD');
    var row1td7btn=docu ment.createElem ent('input');
    row1td7btn.setA ttribute('type' ,'image','id',' Del'+i);
    row1td7btn.src= "test image\del.jpeg" ;
    row1.appendChil d(row1td7);
    tbody.appendChi ld(row1);
    [/CODE]
    I m using the above code to insert a button with image in a dynamically created table.

    Thanks
    daitasri
    Last edited by acoder; Mar 20 '08, 11:49 AM. Reason: Added code tags
  • theS70RM
    New Member
    • Jul 2007
    • 107

    #2
    Originally posted by daitasri
    Hi,
    I am using HTML,Javascript . I m trying to specify source path for a dynamically created element.But its not displaying the image.Please help me.
    I m using the following code:


    var row1td7=documen t.createElement ('TD');
    var row1td7btn=docu ment.createElem ent('input');
    row1td7btn.setA ttribute('type' ,'image','id',' Del'+i);
    row1td7btn.src= "test image\del.jpeg" ;
    row1.appendChil d(row1td7);
    tbody.appendChi ld(row1);

    I m using the above code to insert a button with image in a dynamically created table.

    Thanks
    daitasri

    I'd start by checking (and double checking) your image path. I know its just a test, but does it really have a space in it?

    If not then maybe you can post a link to a fuller example.

    Cheers

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Two problems I can see.

      setAttribute only has two parameters. Separate the type and id settings.

      You've used a backslash for the image path. Use a forward slash instead.

      Comment

      Working...