DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets

  • submit to reddit

Recent Snippets

                    Hello.
I need some help...
I`ve created an eight question form with radio buttoms and checkboxes, and after you`ll answer to all of these questions you should see your final result. 
Well, the first 4 question were created wuth radio buttoms and works very fine but the last 4 that are created with checkboxes didn`t work. when I has to choose more than one answer, the browser didn`t recognize me all of the options that I`ve selected from the checkboxes.

Please help me.                
                    [C#]
 
// read code39 barcode from image
string image = "code39Extended.jpg";
BarCodeReader reader = new BarCodeReader(image, BarCodeReadType.Code39Standard);
// try to recognize all possible barcodes in the image
while (reader.Read()) {
   // get the region information
    BarCodeRegion region = reader.GetRegion();
    if (region != null)
    {
        // display x and y coordinates of barcode detected
        System.Drawing.Point[] point = region.Points;
        Console.WriteLine("Top left coordinates: X = " + point[0].X + ", Y = " + point[0].Y);
        Console.WriteLine("Bottom left coordinates: X = " + point[1].X + ", Y = " + point[1].Y);
        Console.WriteLine("Bottom right coordinates: X = " + point[2].X + ", Y = " + point[2].Y);
        Console.WriteLine("Top right coordinates: X = " + point[3].X + ", Y = " + point[3].Y);
    }
    Console.WriteLine("Codetext: " + reader.GetCodeText());
}
// close reader
reader.Close();


[VB.NET]

 ' read code39 barcode from image
Dim image As String = "code39Extended.jpg"
Dim reader As New BarCodeReader(image, BarCodeReadType.Code39Standard)
' try to recognize all possible barcodes in the image
While reader.Read()
	' get the region information
	Dim region As BarCodeRegion = reader.GetRegion()
	If region IsNot Nothing Then
		' display x and y coordinates of barcode detected
		Dim point As System.Drawing.Point() = region.Points
		Console.WriteLine("Top left coordinates: X = " & point(0).X & ", Y = " & point(0).Y)
		Console.WriteLine("Bottom left coordinates: X = " & point(1).X & ", Y = " & point(1).Y)
		Console.WriteLine("Bottom right coordinates: X = " & point(2).X & ", Y = " & point(2).Y)
		Console.WriteLine("Top right coordinates: X = " & point(3).X & ", Y = " & point(3).Y)
	End If
	Console.WriteLine("Codetext: " & reader.GetCodeText())
End While
' close reader
reader.Close()
                
                    //build URI to upload file
            string fileUploadUri = "http://api.saaspose.com/v1.0/storage/file/test.jpg";
            string UploadUrl = Sign(fileUploadUri);
            // Send request to upload file
            UploadFileBinary("c:\\temp\\test.jpg", UploadUrl, "PUT");

            //build URI to read barcode
            string strURI = "http://api.saaspose.com/v1.0/barcode/test.jpg/recognize?type=AllSupportedTypes";
            // Send the request to Saaspose server
            Stream responseStream = ProcessCommand(Sign(strURI), "GET");
            StreamReader reader = new StreamReader(responseStream);
            // Read the response
            string strJSON = reader.ReadToEnd();
            //Parse the json string to JObject
            JObject parsedJSON = JObject.Parse(strJSON);
            //Deserializes the JSON to a object. 
            RecognitionResponse barcodeRecognitionResponse = JsonConvert.DeserializeObject<RecognitionResponse>(parsedJSON.ToString());
            // Display the value and type of all the recognized barcodes
            foreach (RecognizedBarCode barcode in barcodeRecognitionResponse.Barcodes)
            {
                Console.WriteLine("Codetext: " + barcode.BarCodeValue + "\nType: " + barcode.BarCodeType);
            }

	    \\Here is the RecognitionResponse class
	    public class RecognitionResponse : BaseResponse
    	    {
        	public List<RecognizedBarCode> Barcodes { get; set; }
    	    }

	    \\Here is the RecognizedBarCode class	    
	    public class RecognizedBarCode
    	    {
        	public string BarCodeType { get; set; }
        	public string BarCodeValue { get; set; }
    	    }

	    \\Here is the BaseResponse class	    
	    public class BaseResponse
    	    {
        	public BaseResponse() { }
        	public string Code { get; set; }
        	public string Status { get; set; }
    	    }
                
                    SAP-EDGE is a complete vault for providing offline, online courses  Offering tranging from sap courses which are  abap, abap hr,  bw/bi, bo, bpc, fico, sd, hr, mm , web dynpro, xi, pi, basis, securities with grc,  business one.                
                    [C# Code]

//build URI to get selected link on a page
            string strURI = "http://api.saaspose.com/v1.0/pdf/input.pdf/pages/1/links/1";
            string signedURI = Sign(strURI);
            Stream responseStream = ProcessCommand(signedURI, "GET");
            StreamReader reader = new StreamReader(responseStream);
            string strJSON = reader.ReadToEnd();
            //Parse the json string to JObject
            JObject parsedJSON = JObject.Parse(strJSON);
            //Deserializes the JSON to a object. 
            PdfLinkResponse pdfLinkResponse = JsonConvert.DeserializeObject<PdfLinkResponse>(parsedJSON.ToString());
            Link tempLink = pdfLinkResponse.Link;

	    //Here is the BaseResponse class
	    public class BaseResponse
  	    {
	        public BaseResponse() { }
	        public string Code { get; set; }
	        public string Status { get; set; }
	    }

	    //Here is the PdfLinkResponse class
	    public class PdfLinkResponse : BaseResponse
	    {
	        public PdfLinkResponse() { }
	        public Link Link { get; set; }
	    }

	    //Here is the LinkResponse class
	    public class LinkResponse
	    {
	        public string Href { get; set; }
	        public string Rel { get; set; }
	        public string Title { get; set; }
	        public string Type { get; set; }
	    }

	    //Here is the Link class
	    public class Link
	    {
	        public Link() { }
	        public LinkActionType ActionType { get; set; }
	        public string Action { get; set; }
	        public LinkHighlightingMode Highlighting { get; set; }
	        public Color Color { get; set; }
	    }

	    //Here is the LinkActionType enum
	    public enum  LinkActionType
	    {
	        GoToAction,
	        GoToURIAction,
	        JavascriptAction,
	        LaunchAction,
	        NamedAction,
	        SubmitFormAction
	    }

	    //Here is the LinkHighlightingMode enum
	    public enum LinkHighlightingMode
	    {
	        None,
	        Invert,
	        Outline,
	        Push,
	        Toggle
	    }

	    //Here is the Color class
	    public class Color
	    {
	        public Color() { }
	        public List<LinkResponse> Links { get; set; }
	        public int A { get; set; }
	        public int B { get; set; }
	        public int G { get; set; }
	        public int R { get; set; }
	    }

[VB.NET Code]

'build URI to get selected link on a page
	     Dim strURI As String = "http://api.saaspose.com/v1.0/pdf/input.pdf/pages/1/links/1"
	     Dim signedURI As String = Sign(strURI)
	     Dim responseStream As Stream = ProcessCommand(signedURI, "GET")
	     Dim reader As New StreamReader(responseStream)
	     Dim strJSON As String = reader.ReadToEnd()
	     'Parse the json string to JObject
	     Dim parsedJSON As JObject = JObject.Parse(strJSON)
	     'Deserializes the JSON to a object.
	     Dim pdfLinkResponse As PdfLinkResponse = JsonConvert.DeserializeObject(Of PdfLinkResponse)(parsedJSON.ToString())
	     Dim tempLink As Link = pdfLinkResponse.Link
                
                    //build URI to replace text

string strURI = "http://api.saaspose.com/v1.0/words/input.docx/replaceText";
string signedURI = Sign(strURI);

//serialize the JSON request content
ReplaceText replacetext = new ReplaceText();

// set old string to replace
replacetext.OldValue = OldValue;

// set new string to replace
replacetext.NewValue = NewValue;

// True indicates case-sensitive comparison, false indicates case-insensitive comparision.

replacetext.IsMatchCase = IsMatchCase;

// True indicates the oldValue must be a standalone word.

replacetext.IsMatchWholeWord = IsMatchWholeWord;
string strJSON = JsonConvert.SerializeObject(replacetext);
Stream responseStream = ProcessCommand(signedURI, "POST", strJSON);
StreamReader reader = new StreamReader(responseStream);
string strResponse = reader.ReadToEnd();
//Parse the json string to JObject
JObject pJSON = JObject.Parse(strResponse);
ReplaceTextResponse baseResponse = JsonConvert.DeserializeObject<ReplaceTextResponse>(pJSON.ToString());
//sign URI
signedURI = Sign(baseResponse.DocumentLink.Href + "?format=doc");
//get response stream
responseStream = ProcessCommand(signedURI, "GET");
using (Stream fileStream = System.IO.File.OpenWrite(outputPath))
{
 CopyStream(responseStream, fileStream);
}
responseStream.Close();

//Here is the ReplaceText class
 
public class ReplaceText
{               
 public string OldValue { get; set; }
 public string NewValue { get; set; }
 public bool IsMatchCase { get; set; }
 public bool IsMatchWholeWord { get; set; }
}
                
                    -- source: http://www.apphp.com/index.php?snippet=mysql-selecting-random-row
SELECT * FROM TABLE
ORDER BY RAND()
LIMIT 1                
                    <!-- source: http://www.apphp.com/index.php?snippet=html-5-media-code -->
<form action="upload.php" method="post" enctype="multipart/form-data">
  <input name="upload_files[]" type="file" multiple>
  <input type="submit" value="Upload">
</form>
 
<?php
// PHP code
 that shows how to loop through the data as an array
foreach($_FILES["upload_files"]["name"] as $file){
    echo "<li>".$file."</li>";
}
?>                
                    <!-- source: http://www.apphp.com/index.php?snippet=html-5-media-code -->
<video poster="images/preview.png" width="800" height="600" controls="controls" preload="none"> 
  <source src="media/my_video.mp4" type="video/mp4"></source> 
  <source src="media/my_video.webm" type="video/webm"></source> 
  <source src="media/my_video.ogg" type="video/ogg"></source>
</video>
<audio controls="controls" preload="none">
  <source src="audio/my_music.ogg" type="audio/ogg">
  <source src="audio/my_music.mp3" type="audio/mpeg">
</audio>                
                    <!-- source: http://www.apphp.com/index.php?snippet=html-5-media-code -->
<video poster="images/preview.png" width="800" height="600" controls="controls" preload="none"> 
  <source src="media/my_video.mp4" type="video/mp4"></source> 
  <source src="media/my_video.webm" type="video/webm"></source> 
  <source src="media/my_video.ogg" type="video/ogg"></source>
</video>
<audio controls="controls" preload="none">
  <source src="audio/my_music.ogg" type="audio/ogg">
  <source src="audio/my_music.mp3" type="audio/mpeg">
</audio>