Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Salam, Javascript Problem onClick event

Salam, Javascript Problem onClick event

Scheduled Pinned Locked Moved Web Development
javascriptdatabasehelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mohammed Amine
    wrote on last edited by
    #1

    Salam Guys, I have a small problem right there, here are my 2 small functions in which i'm trying to add two images in each row & set the onclick event of each image to trigger a function depending on the Image Type : I hope you can understand those stuff : function AddRow(id){ HiddenNumber = document.getElementById("MyHidden").value; var Args = AddRow.arguments; var tbody = document.getElementById(Args[0]).getElementsByTagName("TBODY")[0]; row = document.createElement("TR"); var ArgsNumber = Args.length; var Minus = ArgsNumber - 1; for (var i = 0; i < Minus ; i++) { var td = document.createElement("TD"); td.appendChild(document.createTextNode(Args[i+1])); row.appendChild(td); } AddImages("C:/wamp/www/Edit.gif",'Edit'); AddImages("C:/wamp/www/Delete.gif",'Delete'); tbody.appendChild(row); HiddenNumber++; } function AddImages(Path,ImgType) { var td = document.createElement("TD"); var MyImg = document.createElement("input"); MyImg.type = "image"; MyImg.src = Path; if (ImgType == 'Delete') { MyImg.id = "Delete["+HiddenNumber+"]"; MyImg.onclick = DeleteRow(MyImg.id); } else if (ImgType == 'Edit') { MyImg.id = "Edit["+HiddenNumber+"]"; MyImg.onclick = EditRow(MyImg.id); } td.appendChild(MyImg); row.appendChild(td); } function DeleteRow(FrmName) { document.write("Salam, This is the DeleteRow function My Name is "+FrmName); } function EditRow(FrmName) { document.write("Salam, This is the EditRow function My Name is : " + FrmName); } FirstColumn SecondColumn this is the page try it Please. the main problem is with the onclick event, there are 2 cases : First : MyImg.onclick = DeleteRow(MyImg.id); // without qotation markes ""; the sencond one is MyImg.onclick = "DeleteRow("+MyImg.id+")"; // with the 2 qotation markes ""; it drives me crazy Guys, please try your best if you ever have a solution send it to me please i have to deliever the page on time. Salam

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups