Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
Handling form content with JavaScript and Perl

I have a music project in Perl which also requires some JavaScript but I seem to be stuck. I need to execute a program (ffplay) as a command-line application so it runs without displaying a GUI window. The Perl handles the server end of things (sqlite database access). I need JavaScript because I display track names as a button, which when clicked is supposed to run 'ffplay' to play the track named in the button code. But the button click requires JavaScript.

When I click a track name button, it only displays the first track, no matter which one I click.

The following code extracts track names from the DB.

    $sth=$dbh->prepare (qq{select track from tracks where 
artistid=$ArtistID and cdid=$cdID order by track});
    $sth->execute();
    while(@records=$sth->fetchrow_array()) {
         $Track=$records[0];
print<<EndHTML;
<script>
var form=window.document.forms[0]
function process(form) {
        alert ("Track: " + form.elements.Track.value)
    }
</script>
EndHTML
        print qq{<form name="Player">};
        print qq{<input type="button" onClick="process(this.form)" name="Track" value="$Track"><br/>};
        print qq{</form>};
    }
    $sth->finish();
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

SOLVED.

Changed the JavaScript function :

    <html lang="en">
<head>
<script>
function process(value) {
    var form =document.Player
        alert ("Track: " + value)
    }
</script>
</head>
<body>

<form name="Player">
<button onClick="process(this.value)" name="Track1" value="[01] Evenfall.flac">[01] Evenfall.flac</button><br/>
<button onClick="process(this.value)" name="Track2" value="[02] 6am.flac">[02] 6am.flac</button><br/>
<button onClick="process(this.value)" name="Track3" value="[03] Cut.flac">[03] Cut.flac</button><br/>
</form>
</body>

Now the alert correctly tells me which button was clicked.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda