JS on checkbox in grid

QuestionsJS on checkbox in grid
Gary Brett asked 9 years ago

Hello, is it possible to add some JS to a checkbox col to open a URL? So far I have the following which works great on text but doesn't work on checkbox..

http://hastebin.com/iperohageg.php

Thank you

4 Answers
Abu Ghufran answered 9 years ago

When clicked on checkbox, it will open a link if checked.
http://hastebin.com/oxadeziviq.php

Gary Brett answered 9 years ago

Hi there, thank you that does indeed open the window but doesn't pull through the variable..

It returns
http://localhost/live_portal/library/leademail.php/?id={client_id}

where the text link option I posted in hastebin returns
http://localhost/live_portal/library/leademail.php/?id=5

Regards

Gary

Abu Ghufran answered 9 years ago

Set js callback function with onclick

$col = array();
$col["title"] = "Closed";
$col["name"] = "closed";
$col["width"] = "50";
$col["editable"] = true;
$col["edittype"] = "checkbox"; // render as checkbox
$col["editoptions"] = array("value"=>"Yes:No"); // with these values "checked_value:unchecked_value"
$col["editoptions"]["onclick"] = 'send_email(this)';
$cols[] = $col;

and in html code …

<script>
function send_email(o)
{
// get row id
var rowid = jQuery('#list1').jqGrid('getGridParam','selrow');
if (o.checked)
window.open("http://localhost/live_portal/library/leademail.php/?id="+rowid,"newwind&quot;,"height=200,width=550");
}
</script>

Complete code here: http://pastebin.com/Vdu0ykpM

Gary Brett answered 9 years ago

Thank you Abu, great support again.

Your Answer

19 + 15 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?