how to define a value in a href link - href

var button = '<button class="btn">Book Now!</button>';
How do I define a value(id) in my a href link?

As Jérôme Teisseire said in a comment, try to edit this in your string
var button = '<a href="test.html?yourid=' + yourid + '" data-ajax="false">

Related

Getting value of variable from a class to another place

Let's say:
I have class String containing an empty string variable a
In page 1, I need to set variable a = "string here"
In page 2, I need to call the value of a
How can I do that?
from page 1
let nextview = self.storyboard?.instantiateViewController(withIdentifier: "Page2Identifier") as! Page1Controller
nextview.prevscreen = a
self.navigationController?.pushViewController(nextview, animated: true)
in Page 2
var prevscreen = ""

How can i add additional Data(Type) to chart.js

i had already done adding a click handler to each Segment of my doughnut chart with adding the following Code :
$("#myChart").click(
function(evt){
var activePoints = myNewChart.getSegmentsAtEvent(evt);
var chartelementid = activePoints[0].label;
alert(chartelementid);
//$('.details div').css("display", "none");
//$('#' + chartelementid).show();
}
);
This works fine, when finished it should display an additional Div with Details for this segment.
Unfortunality my labels are more then just Single Words, so i'm struggeling to create div ID's with the same name...
My Idea is to add to every Segment an additional Data like value,label, etc. so it could be an ID. but if i just add the ID information to the Segment it will not exist as variable.
Add DataType:
var dataImprove = [
{
value: 30,
color:"#001155",
highlight: "#1c2f7c",
label: "KnowHow Erhalt / Transfer & Aufbau",
id:"test"
}
]
where can i add in chart.js an additional dataType like shown above my ID to be accessible in the DOM?
kind regards Marco
As an alternative pass a JSON string as your label, then intercept to render. For example:
var canvas = document.getElementById(id);
var d = canvas.getContext("2d");
var chart = new Chart(d).Pie(json, {
segmentStrokeWidth: 1,
tooltipTemplate: "<%=label%>", //default the label
customTooltips: function (tooltip) {
// Hide if no tooltip
if (!tooltip) {
return;
}
var tooltipObj = JSON.parse(tooltip.text);
// etc
already found : between line 999 and 1023 in chart.js before drawing - i've added the line
id: ChartElements[0].id,
so the Data with the name ID is in the DOM avaiable.

cannot read property 'setTitleText' of undefined - ccui.Button

I am unable to setTitle Text for ccui.Buttona a widget, its showing cannot read property 'setTitleText' of undefined in Cocos2d-JS
Here's the code
SolutionGrid.setEmptySolutionBox = function(selChild,rChar) {
selChild.active = true;
cc.log("get tag of empty solutionBpx" + selChild.getTag());
var textButtons = ((ccui.Button)(selChild.getChildByTag(5)));
//var textButtons = ccui.Button(selChild.getChildren()[0]);
if(textButtons===null){
cc.log("get tag of empty solutionBpx NULL");
}
///cc.log("get tag of empty solutionBpx" + textButtons.getTag());
textButtons.setTitleText("a");
};
where selChild is node on which ccui.Button is added
Here how its added , I am getting the tag of that node but can not find the ccui.Button as its child
solBox.addChild(textButton,5,5); //solBox is CCNode and text button is ccui.Button
change
var textButtons = ((ccui.Button)(selChild.getChildByTag(5)));
with
var textButtons = selChild.getChildByTag(5);

On/Off icon for boolean field in list_editable modelAdmin

When I put my boolean field in list_editable, it's icon change from the nice on/off icon to the legacy checkbox. Is there a way to keep the field editable with the nice icons ?
I think I've already done this, but can't remember how...
Use you own JavaScript to replace the checkbox with the appropriate image, and use click events to change the image and set the checkbox appropriately.
CSS
.hidden {
position:absolute;
left:-99999px;
width:0;
height:0;
overflow:hidden;
}
JS
(function($){
var on_image = '/static/admin/img/admin/icon-yes.gif';
var off_image = '/static/admin/img/admin/icon-no.gif';
$(document).ready(function(){
var $checkbox = $('.checkbox_field input');
// Can't simply `hide()` as its value will not be posted
$checkbox.addClass('hidden');
var $img = $('<img/>');
if ($checkbox.attr('checked')) {
$img.attr('href', on_image);
$img.attr('alt', 'On');
} else {
$img.attr('href', off_image);
$img.attr('alt', 'Off');
}
$img.insertAfter($checkbox);
$img.click(function(){
var $img = $(this);
var $checkbox = $img.siblings('input');
if ($img.attr('href') == on_image) {
$img.attr('href', off_image);
$img.attr('alt', 'Off');
$checkbox.attr('checked', false);
} else {
$img.attr('href', on_image);
$img.attr('alt', 'On');
$checkbox.attr('checked', true);
}
});
});
)(django.jQuery);

How to get source of the image using RegularExpressions in AS3?

I just want to write a proper regex to get the source of the image from given html text.
//HTML TEXT: <img src="angry.gif" alt="Angry face" />
var regEx = //regex Here
var source:Object = regEx.exec(htmlText);
var regex:RegEx = /src="(.*?)"/i;
var source:String = regex.exec(htmlText)[1];
var str:String="Content <img src='imagePath01.jpg' width='88' height='88'/> content content content <img src='imagePath01.jpg' width='88' height='88'/>";
var imgRegExp:RegExp = /<img[^>]+>/g;//Get (add 'g' end regex) all img in content;
var imgArr:Array = str.match( imgRegExp );
for(var i:uint=0;i<imgArr.length;i++){
trace(imgArr[i]);
//Get src from img;
var imgXML:XML = XML(imgArr[i]);
trace("src: "+imgXML.#src);
}
Happy code !