Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Changing the onClick parameter/value dynamically
Old 10-06-2006, 04:19 PM Changing the onClick parameter/value dynamically
the12thplaya's Avatar
Experienced Talker

Posts: 38
Trades: 0
Hi

I have a list of members and each member has a delete button next to them which calls a function and sets a confirm window/layer to visible when clicked. On the confirm window/layer I have two buttons Yes and No. No sets the confirm window/layer to hidden.

I'm having trouble with the Yes button because I need to set the onClick value of the Yes button so that it will contain a url with the unique details so that the php page knows who to delete.

Here's some of the code I've been playing around with...

The delete button next to each member:

<img src="images/os/programs/declaration/del-player-out.gif" onclick="deleteMemberConfirm('', '', '', 'Delete Member', 'Are you sure you want to delete ....?')");

The function the delete button calls:

function deleteMemberConfirm(fuid, fgid, fpid, ftitle, fmessage) {
document.getElementById("confirmTitle").innerHTML = ftitle;
document.getElementById("confirmMessage").innerHTM L = fmessage;
document.getElementById("confirmWindow").style.vis ibility = 'visible';
document.getElementById("confirmYes").SetAttribute ("onClick", "removemember.php?gid=" + fgid + "&pid=" + fpid + "&uid=" + fuid);
}

The button I want to change the onClick value:

<input name="confirmYes" type="button" id="confirmYes" value="Yes" onClick="">



The only thing that isn't working in the function is the document.getElementById("confirmYes").SetAttribute .... line. I've tried different ways but whenever I look at the source code the value is blank.

I also know that I'm not passing any of the unique details through to the function yet so the url will not be complete. I'm really just trying to get the onClick value to change to anything before I pass those through.

Any help will be appreciated as I'm not finding much on google.

I can do it via php and set the onclick value by refreshing the page before the confirm window is shown but I'm trying to cut down pointless loads like that.

Thanks

Kevin
the12thplaya is offline
Reply With Quote
View Public Profile Visit the12thplaya's homepage!
 
 
Register now for full access!
Old 10-06-2006, 04:39 PM Re: Changing the onClick parameter/value dynamically
the12thplaya's Avatar
Experienced Talker

Posts: 38
Trades: 0
I tried this and found that it worked in Firefox but not Internet Explorer which is what I've been trying it in for the last hour or two:

document.getElementById("confirmYes").setAttribute ("onclick", "alert('working');");
the12thplaya is offline
Reply With Quote
View Public Profile Visit the12thplaya's homepage!
 
Old 10-06-2006, 05:51 PM Re: Changing the onClick parameter/value dynamically
the12thplaya's Avatar
Experienced Talker

Posts: 38
Trades: 0
I found a solution:

function deleteMemberConfirm(fuid, fgid, fpid, ftitle, fmessage) {
document.getElementById("confirmTitle").innerHTML = ftitle;
document.getElementById("confirmMessage").innerHTM L = fmessage;
document.getElementById("confirmWindow").style.vis ibility = 'visible';
document.confirmForm.confirmURL.value = 'www.google.co.uk';
//Will replace google with the function parameters.
}

function deleteMember() {
alert(document.confirmForm.confirmURL.value);
//Will replace this with the URL and then load it
}

The Yes button...

<input name="confirmYes" type="button" value="Yes" onClick="deleteMember()">

And a hidden field...

<input name="confirmURL" type="hidden" value="">

This seems to work so far, for both IE and Firefox.

Last edited by the12thplaya; 10-06-2006 at 06:08 PM..
the12thplaya is offline
Reply With Quote
View Public Profile Visit the12thplaya's homepage!
 
Old 10-17-2006, 07:15 AM Re: Changing the onClick parameter/value dynamically
seomumbai's Avatar
Skilled Talker

Posts: 98
Trades: 0
I think the problem comes with the name u declared there when your declaring the confirm window.
seomumbai is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Changing the onClick parameter/value dynamically
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19484 seconds with 12 queries