Gossamer Forum
Home : Products : DBMan : Installation :

Perl / Javascript confict

Quote Reply
Perl / Javascript confict
I will post some code, that works fine for me, only when I define the perl work in the Javascript myself. The problem is, that a list is defined, depended on some fields in my DB. This is the code, that must be modified:
Code:
$Merk_number = 2; # field number of the Make field
$Type_number = 4; # field number of the Type field

open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if (!(grep $_ eq $fields[$Type_number], @{$Types{$fields[$Merk_number]}})) {
push (@{$Types{$fields[$Merk_number]}}, $fields[$Type_number]);
}
if (!(grep $_ eq $fields[$Merk_number], @Merks)) {
push (@Merks, $fields[$Merk_number]);
}
}
close DB;

#=====================================================================#
#==# IN THIS PART THE PERL MUST DO HIS WORK #==#
#==# ONLY I DO NOT KNOW HOW... #==#
#=====================================================================#

<Script Language="Javascript"> # MUST BE HERE!!

foreach $Merk (sort @Merks) {
$Array = "Array";
$Mark = "$Merk$Array";
print qq~


var $Mark = new Array("('Select Type','',true,true)",<br>~;
foreach $type (sort @{$Types{$Merk}}) {
print qq~"('$type')",~;
}
print qq~"('Alle modellen')");<br>~;
});
==================
I clean this up a bit, because I solve this with an extern '.js' file, see the code in my reply below.

[This message has been edited by mart (edited September 14, 1999).]
Quote Reply
Re: Perl / Javascript confict In reply to
Have you tried putting the full Javascript between the <head></head> anchors? That could be part of the problem.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Perl / Javascript confict In reply to
Hi Elliot,
I am one step further with this.
I let DBMan make a seperate file and let the Java read that as a '.js' source. It work, but...
When DBMan makes that file, there must be some '"' in it. I found out, that this is the reason for some syntax-errors. Because the 'print-to-a-file' command needs a starting '"' and also a closing '"', I cannot put this character in the file. Is it possible to change the printing command or that " after the 'print' command to another character, so I can put that " in my file??? With a solution for this, I solve my problem and have a great mod ready.
I'll post the code below and take out the big code above.

BTW, how is Carol???
Code:
open (TYPES, ">/opt/guide/www.autorandstad.nl/HTML/temp.js");
foreach $Merk (sort @Merks) {
$Array = "Array";
$Mark = "$Merk$Array";

print TYPES " # Here is the start "
var $Mark = new Array("('Select Type','',true,true)",\n";
foreach $type (sort @{$Types{$Merk}}) {
print TYPES "'('$type')',";
}
print TYPES "('Alle modellen')');\n";
}

close TYPES;



[This message has been edited by mart (edited September 14, 1999).]
Quote Reply
Re: Perl / Javascript confict In reply to
Got another CGI Error when I clicked on Zoeken. The drop down menu looks cool, but didn't seem to do anything when I clicked on the button.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Perl / Javascript confict In reply to
I don't know...I emailed her last Thursday and she replied that she hoped to be back on the Forum by Saturday. But I guess she is still not feeling well. Frown

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Perl / Javascript confict In reply to
OK, give her my regards and all the best.
Meanwhile I solve my problem, I did it with an extern file, build by DBMan, and called by a Javascript as .js file. The printing-to-a-file with the " characters, I solve with the assistance of a 'Perl' site, it says that it could be done with:
print FILE qq/whatever you will print, incuding the " characters, closed with\n/; ,so the mod is working. If you are curious, take a look ( www.autorandstad.nl/start ) and know, that all the values in the select fields are taken out of the DB, so every search action is a hit!! If you or anybody is interested, I'll post all code on the forum. I cannot wait, to tell Carol that this thing, we started a while ago, finely works.

Thanks and greetings,
---------
Mart.
Quote Reply
Re: Perl / Javascript confict In reply to
Mart,

I would recommend posting this mod in the Resource Center. I "spoke" with Alex yesterday and Gossamer Threads is in the process of installing a new forum software. My fear is that if you post it in the current forums, it may be lost in the shuffle.

So, posting it in the Resource Center is the better choice. You may want to ask Carol's permission since she assisted you with the codes, right? Smile

BTW: I receive a cgi error when accessing the URL you gave me.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Perl / Javascript confict In reply to
OK, when the time is right, I'll ask her. The CGI-error might be because in the passed few hours I was busy to take out some bugs of it (IE/Netsc), but I think you can try it now. Please give me your professionel thought about this.

Thanks in adv.
--------
Mart.
Quote Reply
Re: Perl / Javascript confict In reply to
OK,
Now I go to sleep, everything is working fine now. Just the footer and some other little things. Maybe you (Elliot) can have a look again, if there are any CGI-errors of other misconfigurations?? I'll stand open for any tips.

BTW, in the 'drop-down-menu' on the 'Hoofdmenu', you don't have to click on any button, only choose a 'Make'(=Merk) and then in the other field on the left side of this you can choose a 'Model'(=Type)it always give the right Models with the right 'Makes'(isn't that fun??...), with selecting the Model, an 'onChange'-event in Java, that will do the searching.

Thanks for the attention.

Greetings,
--------
Mart.

[This message has been edited by mart (edited September 15, 1999).]