Posts

Showing posts with the label Variables

Assign Command Output To Variable In Batch File

Answer : A method has already been devised, however this way you don't need a temp file. for /f "delims=" %%i in ('command') do set output=%%i However, I'm sure this has its own exceptions and limitations. This post has a method to achieve this from (zvrba) You can do it by redirecting the output to a file first. For example: echo zz > bla.txt set /p VV=<bla.txt echo %VV% You can't assign a process output directly into a var, you need to parse the output with a For /F loop: @Echo OFF FOR /F "Tokens=2,*" %%A IN ( 'Reg Query "HKEY_CURRENT_USER\Software\Macromedia\FlashPlayer" /v "CurrentVersion"' ) DO ( REM Set "Version=%%B" Echo Version: %%B ) Pause&Exit http://ss64.com/nt/for_f.html PS: Change the reg key used if needed.

Check If Object Exists In JavaScript

Answer : You can safely use the typeof operator on undefined variables. If it has been assigned any value, including null, typeof will return something other than undefined. typeof always returns a string. Therefore if (typeof maybeObject != "undefined") { alert("GOT THERE"); } There are a lot of half-truths here, so I thought I make some things clearer. Actually you can't accurately tell if a variable exists (unless you want to wrap every second line into a try-catch block). The reason is Javascript has this notorious value of undefined which strikingly doesn't mean that the variable is not defined, or that it doesn't exist undefined !== not defined var a; alert(typeof a); // undefined (declared without a value) alert(typeof b); // undefined (not declared) So both a variable that exists and another one that doesn't can report you the undefined type. As for @Kevin's misconception, null == undefined . It is due to type c...

CodeIgniter Select Query

Answer : Thats quite simple. For example, here is a random code of mine: function news_get_by_id ( $news_id ) { $this->db->select('*'); $this->db->select("DATE_FORMAT( date, '%d.%m.%Y' ) as date_human", FALSE ); $this->db->select("DATE_FORMAT( date, '%H:%i') as time_human", FALSE ); $this->db->from('news'); $this->db->where('news_id', $news_id ); $query = $this->db->get(); if ( $query->num_rows() > 0 ) { $row = $query->row_array(); return $row; } } This will return the "row" you selected as an array so you can access it like: $array = news_get_by_id ( 1 ); echo $array['date_human']; I also would strongly advise, not to chain the query like you do. Always have them separately like in my code, which is clearly a lot easier to read. Please also note that if you specify the table name...

Change CSS Variable Using JQuery

Answer : You may change the css variable using plain JavaScript elem.style.setProperty("variableName", "variableProp"); $("html").on('click', function() { $("body").get(0).style.setProperty("--color", "hotpink"); }); body { --color: blue; background-color: var(--color); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> click me! Simplest solution IMHO: Change a class, that in turn changes the default color: html { --defaultColor: teal; } html.someOtherDefaultColor { --defaultColor: rebeccapurple; } $("#clickToChange").click(function(){ $(html).toggleClass("someOtherDefaultColor"); }); See question Setting a CSS custom property (aka CSS variable) through JavaScript or jQuery The method in question is document.body.style.setProperty($property, value); where $property is the CSS variable.

Add Php Variable Inside Echo Statement As Href Link Address?

Answer : Try like HTML in PHP : echo "<a href='".$link_address."'>Link</a>"; Or even you can try like echo "<a href='$link_address'>Link</a>"; Or you can use PHP in HTML like PHP in HTML : <a href="<?php echo $link_address;?>"> Link </a> you can either use echo '<a href="'.$link_address.'">Link</a>'; or echo "<a href=\"$link_address\">Link</a>'; if you use double quotes you can insert the variable into the string and it will be parsed. Basically like this, <?php $link = ""; // Link goes here! print "<a href="'.$link.'">Link</a>"; ?>