?
Solved

I have a link to a javascript function and I need the link to work as a button

Posted on 2010-01-06
7
Medium Priority
?
297 Views
Last Modified: 2013-11-19
I have this line, which work fine (also in codesnippet):

<a href="mailto: name@domain.com" onclick="this.href += email_foresporsel()">Send forespørsel</a>

and of course I do have the javascript it prosesses (see codesnippet)

Challenge: I need the link to be displayed as a button, not just as text. Probably easy ?



The link (that I want to be a button)

<a href="mailto: name@domain.com" onclick="this.href += email_foresporsel()">Send forespørsel</a>


JAVASCRIPT:

function email_foresporsel(){
      var subject = "Ønsker spesialtilbud på disse hotellene";
      var body = "";

      if(document.getElementById("dinevalgDiv")){
            body = document.getElementById("dinevalgDiv").innerHTML;
      }

      return "?subject=" + encodeURIComponent(subject) + "&body=" + body;
}

Open in new window

0
Comment
Question by:granholmen
7 Comments
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 26196263
Not tested
<form><input type=button value="Send forespørsel" name ="mailto: name@domain.com" onclick="this.name += email_foresporsel()"></form>

Open in new window

0
 

Author Comment

by:granholmen
ID: 26196306
->itkamaraj
I'm sorry, nothing happens  - the button does not work. Actually, I've already tried that one myself.
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26200744
just to give an idea
<div style='background-color:blue;width:50;height:20;'><a href='#' onclick=''>asda</a> </div>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26200795
0
 
LVL 1

Accepted Solution

by:
npcw earned 1000 total points
ID: 26202420
use the button code
<button></button>
place in conted of link
like:
<a href="mailto: name@domain.com" onclick="this.href += email_foresporsel()"><button>Send forespørsel</button></a>

the full code is atacht
<a href="mailto: name@domain.com" onclick="this.href += email_foresporsel()"><button>Send forespørsel</button></a>
<SCRIPT LANGUAGE="JavaScript">
function email_foresporsel(){
      var subject = "Ønsker spesialtilbud på disse hotellene";
      var body = "";

      if(document.getElementById("dinevalgDiv")){
            body = document.getElementById("dinevalgDiv").innerHTML;
      }

      return "?subject=" + encodeURIComponent(subject) + "&body=" + body;
}

</sript>

Open in new window

0
 

Author Comment

by:granholmen
ID: 26203867
npcw solution worked Perfect ;)
0
 

Author Comment

by:granholmen
ID: 26204631
Actually --> Something weird is happening: The button always generates two emails....I've tried hard to find out why, but I am stuck....
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question