This topic is locked
[SOLVED]

 Show/hide with checkbox using javascript

2/22/2016 8:38:19 AM
ASPRunner.NET General questions
C
ccvvccc author

Hi guys,
I have two Fields.
Video (bit) and Video_Link (nvarchar(150))
I would like to show Video_Link field based on Video checbox.
I have added the following code on my JavaScript onLoad Event, but not working.
Can you please help?
var cat = Runner.getControl(pageid, 'Video');

var c = Runner.getControl(pageid, 'Video_Link ');
pageObj.hideField("Video_Link ");
cat.on('change',

function(){ if (this.checked == true){

pageObj.showField("Video_Link ");

}

else{

pageObj.hideField("Video_Link ");

}
});
Video_Link is not shown on Load. But I dont know how to detect whether checkbox is checked or not?

C
ccvvccc author 2/22/2016

I have found the solution.
On Add Page's javascript on load event
var cat = Runner.getControl(pageid, 'Video');

var c = Runner.getControl(pageid, 'Video_Link');
pageObj.hideField("Video_Link");
cat.on('change', function(e){
if (this.getValue() == 'on'){

pageObj.showField("Video_Link");

}

else{

pageObj.hideField("Video_Link");

}
});
On Edit Page's javascript on load event
var cat = Runner.getControl(pageid, 'Video');

var c = Runner.getControl(pageid, 'Video_Link');
if (cat.getValue() != 'on'){

pageObj.hideField("Video_Link");

}
cat.on('change', function(e){
if (this.getValue() == 'on'){

pageObj.showField("Video_Link");

}

else{

pageObj.hideField("Video_Link");

}
});
This works like a charm. But I dont know how to do it in Inline edit.

Sergey Kornilov admin 2/23/2016

Here is how you can adjust it so it also works in inline mode.

var cat = Runner.getControl(pageid, 'Video');

var c = Runner.getControl(pageid, 'Video_Link');
if (cat.getValue() != 'on'){

pageObj.hideField("Video_Link");

$("input[id^=value_Video_Link]").hide();

}
cat.on('change', function(e){
if (this.getValue() == 'on'){

pageObj.showField("Video_Link");

$("input[id^=value_Video_Link]").show();

}

else{

pageObj.hideField("Video_Link");

$("input[id^=value_Video_Link]").hide();

}
});
C
ccvvccc author 3/2/2016



Here is how you can adjust it so it also works in inline mode.

var cat = Runner.getControl(pageid, 'Video');

var c = Runner.getControl(pageid, 'Video_Link');
if (cat.getValue() != 'on'){

pageObj.hideField("Video_Link");

$("input[id^=value_Video_Link]").hide();

}
cat.on('change', function(e){
if (this.getValue() == 'on'){

pageObj.showField("Video_Link");

$("input[id^=value_Video_Link]").show();

}

else{

pageObj.hideField("Video_Link");

$("input[id^=value_Video_Link]").hide();

}
});



Thanks. It is working even in inline mode with your code.