Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass HTML Form data to Dymo Printer with Javascript

Status
Not open for further replies.

Sporker

Technical User
Mar 14, 2007
1
US
Hello! I'd really love some help with this, if you could!

I work for a meeting/event planning company and we handle conferences and meetings and deal with Registration and name badge printing. Our goal is to be able to Print Name badges from a registration form of some kind that can also save the data in some file format or ideally write to a database.

Here is an example form that is an example of how it could look (a conference attendee enters the info on the first page, continues and inserts the record into the database, then clicks “Print” on the final page):


I've been trying to come up with a solution from the SDK files installed on my PC by the Dymo program and separate SDK files but the problem is that I can’t figure out how to tell the Dymo printer what data is in those information fields in the form.

Is there a way to map the HTML form fields to the Dymo printer? I created a custom label and set the input fields for variable data so what am I missing to connect the HTML Form to the printer output?

This is the javascript file included with the SDK information for the Dymo LabelWriter 400 turbo:

<<<<<<<<<<<<<<<<<<<<<

<html>
<head>
<title>Label Printing Demo</title>
</head>

<body>
<h1>JavaScript Label Printing Demo</h1>

<form>
<INPUT TYPE="BUTTON" NAME="PrintBtn" VALUE="Print Label" OnClick="PrintBtnClicked()">
</form>

<SCRIPT>
function PrintBtnClicked()
{
var DymoAddIn, DymoLabel;
DymoAddIn = new ActiveXObject('DYMO.DymoAddIn');
DymoLabel = new ActiveXObject('DYMO.DymoLabels');

if (DymoAddIn.Open('C:\\Documents and Settings\\All Users\\Documents\\DYMO Label\\Label Files\\Address (30252, 30320, 30572).LWL'))
{
DymoLabel.SetAddress(1, 'Pablo Martini1\nSAMPLE Corporation\n333 W. Fantasy World\nSantaland, NP 99999-9999');
DymoAddIn.Print(1, true);

// this is how to print to the "Right Roll" of a TwinTurbo
//DymoAddIn.StartPrintJob();
//DymoAddIn.Print2(1, false, 1); // 0 = left roll, 1 = right roll, 2 = auto-switch
//DymoAddIn.EndPrintJob();
}
else if (DymoAddIn.Open('C:\\Program Files\\DYMO Label\\Label Files\\Address (30252, 30320, 30572).LWL'))
{
DymoLabel.SetAddress(1, 'Pablo Martini1\nSAMPLE Corporation\n333 W. Fantasy World\nSantaland, NP 99999-9999');
DymoAddIn.Print(1, true);

// this is how to print to the "Right Roll" of a TwinTurbo
//DymoAddIn.StartPrintJob();
//DymoAddIn.Print2(1, false, 1); // 0 = left roll, 1 = right roll, 2 = auto-switch
//DymoAddIn.EndPrintJob();
}
else if (DymoAddIn.Open('C:\\Program Files\\Dymo Label\\Label Files\\Address (30252, 30320).LWT'))
{
DymoLabel.SetAddress(1, 'Pablo Martini2\nSAMPLE Corporation\n333 W. Fantasy World\nSantaland, NP 99999-9999');
DymoAddIn.Print(1, true);

// this is how to print to the "Right Roll" of a TwinTurbo
//DymoAddIn.StartPrintJob();
//DymoAddIn.Print2(1, false, 1); // 0 = left roll, 1 = right roll, 2 = auto-switch
//DymoAddIn.EndPrintJob();
}
else
alert('Error: Label file Not Found!');
}
</SCRIPT>

</body>
</html>

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

The above line "DymoLabel.SetAddress" function seems to be the key or place where I'd put the objects or form data fields, but I'm clueless. Can anyone help, please?

Thank you for your help!
 
If I understand you correctly, you want to take the data entered into the form and use that instead of the hard-coded string in the 'SetAddress' call.

That being the case, you could use something like this:

Code:
var badgeName = document.getElementById('pro_badge_name').value;

var companyName = document.getElementById('pro_organization').value;

DymoLabel.SetAddress(1, badgeName + '\n' + companyName);

Also, wouldn't it make more sense to have your list of state codes ordered alphabetically? Right now, it seems completely random.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top