Wednesday, 24 February 2016

     concat method is used to join two or more arrary or strings. This method does not change the existing(old) value, but return the joined value(new value).

Syntax

string1.concat(string2);

or

array1.concat(array2);


Example 1

var str1="Allinworld";

var str2="99";



alert(str1.concat(str2));



Example 2

 var ar1 = ["A","B","C"];
 var ar2 = ["D","E","F"];

alert(ar1.concat(ar2));



Example Program:- (Editor)


Editor is Loading...

Advertisement

          Return the selected value from string, we can select the string value by using index. If the specified index value is outof range then it will return the -1.
slice() method for array values


Syntax

     string.slice(startindex[,endindex]);

 endindex is the optional.

Example

str="Merbin joe" ;



alert(str.slice(3));   //return from 3rd character ["bin joe"]

alert(str.slice(3,5)); //return 3 to 5th character ["bi"]

Example Program:- (Editor)


Editor is Loading...

Advertisement

     Return the selected value from array, we can select the array value by using index. If the specified index value is out of range then it will return the -1.
slice() method for string values


Syntax

     string.slice(startindex[,endindex]);

 endindex is the optional.

Example :

var fruits = ["Jan", "Feb", "Mar", "Apr", "May"];

alert(fruits.slice(1)); //return 2 to 5th value  (Not removed)



alert(fruits.slice(2,4));  //return 3 to 4th value

Example Program:- (Editor)


Editor is Loading...

Advertisement

     In javascript we can call a function while clicking html elements in three types, they are define in following example.

1) onclick
2) object.onclick
3) addEventListener


1) onclick:
     This is type is define inside the html tag. When you want to call a function in while clicking you can use the onclick attribute inside the html elements.

Syntax

<element onclick="script or function calling">


Example

<script>

 function cl_fun()

{

  alert("Function Called");

}

</script>



 <input type="button" onclick="cl_fun();" value="Click Here">


2) object.onclick
     In this method we are call a function using html elements id.

Syntax

var obj=document.getElementById("element_id");

obj.onclick=function(){/*script here*/};



Example

<script>

 var obj=document.getElementById("btnid");

 obj.onclick=function(){alert("Function Called");};



or

 var obj=document.getElementById("btnid");

 obj.onclick=function_name;

</script>



  <input type="button" id="btnid" value="Click Here">


3) addEventListener
     addEventListener also define such as object.onclick, the example is shown below.

Syntax:

 var obj=document.getElementById("element_id");

obj.addEventListener("click",function(){/*script here*/},useCapture);



 or

 var obj=document.getElementById("element_id");

 obj.addEventListener("click",function_name,useCapture);


addEventListener false why?
       The third parameter is If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered listener before being dispatched to any EventTargets beneath it in the DOM tree. Events which are bubbling upward through the tree will not trigger a listener designated to use capture. See DOM Level 3 Events for a detailed explanation.

Example

<script>

 var obj=document.getElementById("btnid");

 obj.addEventListener("click",function(){alert("Function Called"),false};

</script>



 <input type="button" id="btnid" value="Click Here">


Example Program:- (Editor)


Editor is Loading...

Advertisement




Tag:
click function using javascrip in allinworld99, click event in javascript allinworld99

Tuesday, 23 February 2016

     In this section we are going to see how to convert the pure html and css code to pdf using itextsharp and itexsharp.xmlworker dll's.


Download itextsharp.xmlworker.dll
Downlaod itextsharp.dll

Note:
     You should use the same version of the itextsharp.dll and itextsharp.xmlworker.dl

If you not use the same version you will see like the following error.
 Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1705: Assembly 'itextsharp.xmlworker, Version=5.5.8.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' uses 'itextsharp, Version=5.5.8.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' which has a higher version than referenced assembly 'itextsharp, Version=5.5.0.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca'

Source Error:


[No relevant source lines]

Source File:    Line: 0


itextsharp.xmlworker and itextsharp error higher version
Client Side code:

<asp:HiddenField runat="server" ID="selectedhtml" />

<asp:ImageButton ID="lnkPDF" ImageUrl="~/App_Themes/Blue/images/adobe.jpg" ToolTip="Export to PDF"
                        runat="server" OnClick="lnkPDF_Clicked"></asp:ImageButton>&nbsp;&nbsp;&nbsp;

<div id="testdiv">
<div id="tdiv1">
<img src="sample.jpg" />
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Merbin</td>
<td>29</td>
</tr>
<tr>
<td>Franklin</td>
<td>30</td>
</tr>
<tr>
<td>Justus</td>
<td>45</td>
</tr>
</table>
</div>
</div>


 <script>

     var btnobj = document.getElementById("<%=lnkPDF.ClientID%>");
     btnobj.addEventListener("click", myfun);

     function myfun() {

             document.getElementById('<%=selectedhtml.ClientID%>').value = document.getElementById('testdiv').innerHTML.replace(/(<img[^>]+)/g, "$1 /");

         }

</script>  


HTML code are converted into xhtml and after only it will process so we have some limitation eg) you should need to close the image tag and etc.
If you are get the innerHTML content the image close tag won't get you so you can replace the image close tag by using the following line.

document.getElementById('<%=selectedhtml.ClientID%>').value = document.getElementById('testdiv').innerHTML.replace(/(]+)/g, "$1 /");


Server Side Code:
protected void lnkPDF_Clicked(object sender, EventArgs e)
{

Document Doc;
Doc = new Document(PageSize.A4, 10f, 10f, 50f, 20f);

string filename = "PaySlip";
string outXml = selectedhtml.Value;
outXml = "<style>#tdiv1{background:red;color:white;}</style>" + outXml;
outXml = outXml.Replace("px", "");
outXml = outXml.Replace("<br>", "<br/>");

MemoryStream memStream = new MemoryStream();
TextReader xmlString = new StringReader(outXml);
using (Document document = new Document())
{
PdfWriter writer = PdfWriter.GetInstance(document, memStream);
document.Open();
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(outXml);
MemoryStream ms = new MemoryStream(byteArray);
XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, ms, System.Text.Encoding.UTF8);
document.Close();
}

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=" + filename + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.BinaryWrite(memStream.ToArray());
Response.End();
Response.Flush();
}



No need to put the px in styles, so you can replace the px to "" value by using the following line.
outXml = outXml.Replace("px", "");

innerHTML won't close the <br> tag so you should need to replace the <br> tag to <br/>.
outXml = outXml.Replace("<br>", "<br/>");



View Generated PDF file




Tags:
convert pdf to html in allinworld99, css not support while generating pdf from html code in allinworld99, background color not supported in htmlworker in allinworld99, how to convert htmlwoker to xmlworker in allinworld99,

Monday, 22 February 2016

     The Boolean() constructor function takes one parameter to be converted to a boolean value (i.e., true or false). Any valid JavaScript value that is not 0, -0, null, false, NaN, undefined, or an empty string(""), will be converted to true. Below, we create two boolean object values. One true, one false.

""  => empty string returns false value
"any val"  => string returns true value
3<4   => returns true
4<3  => returns false
null  => returns false

Syntax

     Boolean(condition);

Example

     alert(Boolean(3>4));


Example Program:- (Editor)


Editor is Loading...

Advertisement

Tags:
Boolean() method in allinworld99, Boolean() method will return true or false value

Friday, 19 February 2016

     If the condition is true the if statements are executed otherwise the next statement will execute.

Syntax

     if(condition)

     {

        Statements;

     }


Flow chart
if statement flowchart


Example

   if(10<50)

   {

      alert("Executed");

   }



Example Program:- (Editor)


Editor is Loading...

Advertisement




Tags:
if statement in javascript allinworld99, if statement in java allinworld99, if statement in c, if statement in cpp, if flow chart in allinworld99,

Tuesday, 16 February 2016

     if...else is used to check the condition and if the condition is true the if part statements are executed and if the condition is false the else part statements are executed.

Syntax

  if(condition)
  {
     Statements;
  }
  else
  {
     Statements;
  }


Flow Chart:




























Example:

if(10<5)
{
   alert("5 is big");
}
else
{
   alert("10 is big");
}




Example Program:- (Editor)


Editor is Loading...

Advertisement



Tags:
if else in allinworld99, allinworld99 to solve if else condition
     The if...Then...else statement is fundamental to many programming languages. In Intent language, this statement can appear in several different forms.
     allinworld99 recommended you to learn logical wise concept.

Syntax

   if(condition)

  {

    statements;

  }

  else if(condition)

  {

    statements;

  }

  else

 {

    statements;

  }


Flow Chart:


if then else if flow chart


Example:

if(6<10)

{

   alert("10 is big");

}

else if(10<15)

{

   alert("15 is big");

}

else

{

   alert("No condition matched");

}





Example Program:- (Editor)


Editor is Loading...

Advertisement



Tags:
if else if then else in allinworld99, allinworld99 in if else if then else

Monday, 15 February 2016

      A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.

Syntax

switch(expression)

{

  case condition_variable-1:

          statements;

          break;

  case condition_variable-2:

          statements;

          break;

  case condition_variable-3:

          statements;

          break;

      --------------

      --------------

      --------------

  case condition_variable-n:

          statements;

          break;



default:

           statements;

}


Example

a=3;

switch(a)

case 1:

{

      alert("One");

      break;

case 2:

      alert("Two");

      break;

case 3:

      alert("Three");

      break;

default:

       alert("no condition matched");

}



Flow Chart


Example Program:- (Editor)


Editor is Loading...

Advertisement





Tags:
switch case statement in allinworld99, switch in javascript, case statement in javascript,switch and case in allinworld99 javascript.

Friday, 12 February 2016

Why For Loops?

1) Like all loops, "for loops" execute blocks of code over and over again.
2) The advantage to a for loop is we know exactly how many times the loop will execute before the loop starts.

Syntax

for(initialization; condition; increment/decrement)

{

  Statements;

}

Example:

for(i=0;i<=5;i++)

{

  statements;

}


Flow chart of for loop:
     In the following flowchart is draw similar to the above example, don't forget to see the whole explanation about the flowchart.

for loop execution flow chart






















Step 1:
     Start Initialization, if you want to initialize  any value you can assign here this is optional.

Step 2:
     Conditions are return true or false value this also optional, some examples are

Conditions
3>5        => return False
6<=6     =>  return True
3==3     =>  return True

Symbols
<           => Less than
>           => Greater than
=           => Equal
<=         => less than or equal
>=         => greater than or equal
!            => Not
!=          => Not equal

     If true then inside the for loop statements executed.

Step 3:
     Statement, in this part have any type of statements like alert, function calling, if, for and etc. Then next it will go to increments/Decrements part.

Step 4:
     Increment/Decrements this is also optional and here we can increase or decrease the value. Then go to check the condition again.

Step 5:
     Condition again check and repeat the process again, when the condition is return false value the control will go to Next Statements.


for(i=0;i<=5;i++)

{

  alert(i);

}


     Below I write all the execution steps, if you new to for loop please watch all steps.

start
i=0

i<=5  (0<=5)   => True
alert the i value (alert 0)
i++ [i=i+1]  (i=0+1)  [i=1]

i<=5    (1<=5)   => True
alert 1
i++  (i=1+1)  [i=2]

i<=5   (2<=5)  => True
alert 2
i++ (i=2+1)  [i=3]

i<=5  (3<=5)  => True
alert 3
i++  (i=3+1)  [i=4]

i<=5  (4<=5) => True
alert 4
i++  (i=4+1)  [i=5]

i<=5   (5<=5)  => True
alert 5
i++  (i=5+1)  [i=6]

i<=5   (6<=5)   => False

Then go to outside of the for loop.





Example Program:- (Editor)


Editor is Loading...

Advertisement





Tags:
for loop in allinworld99, for loop in javascript, for loop in c, for loop in c++ cpp, learn for loop in allinworld99

Wednesday, 10 February 2016

     for of loop was introduced in ES6 which allows you to easily iterate over elements of an collection.for of iterates over the values of elements of a collection not the keys. A collection can be an array, set, list, custom collection object etc.

     Earlier to ES6 we had to use for loop or Array�s foreach loop to walk through elements of an collection. ES6 introduced a new way for iteration.

     The following example is help you to read all the value from objects.

Syntax

    for (variable of array_or_object)

    {

       Statements;

    }


Example

    for(i of ar_ob)

      {

        debugger;

        alert("Name : "+i.name);

        alert("Mark : "+i.mark);

      }




Example Program:- (Editor)


Editor is Loading...

Advertisement



Tags:
Read object value using javascript in allinworld99, allinworld99 to get the values of object, how to get the object value in allinworld99.