Add submit and onsubmit function to link

Hello experts
I have a form and using a little script i replace  the submit button with alink.
Now i want to add the onsubmit function to because the way i have this it is not working.
Any help?

<form action="<cfoutput>#CurrentPage#?#QueryString_WADAdboartikel#</cfoutput>" method="post" onSubmit="this.action=this.action+'&PageNum_WADAdboartikel='+PageNum_WADAdboartikel.value" name="goto">
	<a href="#" onClick="document.goto.submit()" >Go to:</a>
     <input type="text"  name="PageNum_WADAdboartikel"  id="PageNum_WADAdboartikel"size="5" />

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawel WitkowskiSenior Javascript DeveloperCommented:
have you tried:


<a href="#" onClick="this.parentNode.submit()" >Go to:</a>

instead of:

<a href="#" onClick="document.goto.submit()" >Go to:</a>
PanosAuthor Commented:
It is not working
       PageNum_WADAdboartikel.value will automatically be appended to the query string, thats how forms work. There is no need to append it at submit time.

        I think you may have some design problems it looks  the forms' action url already has a has a query string as part of it.

       More details may help us.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Pawel WitkowskiSenior Javascript DeveloperCommented:
help us help you :) can you add some example page for that problem ?:)
PanosAuthor Commented:
I made a test page.
The form is working with the submit button but not with the link.
You can test it too.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7" />
<title>Untitled Document</title>
<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfquery name="WADAdboartikel" datasource="#request.dsn#">
SELECT  a.Art_ID,a.Price
FROM artikel  a
<cfparam name="Url.PageNum_WADAdboartikel" default="1">
<cfparam name="url.nrecords" default="1">
<cfset MaxRows_WADAdboartikel="#Url.nrecords#">
<cfset StartRow_WADAdboartikel=Min((PageNum_WADAdboartikel-1)*MaxRows_WADAdboartikel+1,Max(WADAdboartikel.RecordCount,1))>
<cfset EndRow_WADAdboartikel=Min(StartRow_WADAdboartikel+MaxRows_WADAdboartikel-1,WADAdboartikel.RecordCount)>
<cfset TotalPages_WADAdboartikel=Ceiling(WADAdboartikel.RecordCount/MaxRows_WADAdboartikel)>
<cfset QueryString_WADAdboartikel=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset tempPos=ListContainsNoCase(QueryString_WADAdboartikel,"PageNum_WADAdboartikel=","&")>
<cfif tempPos NEQ 0>
  <cfset QueryString_WADAdboartikel=ListDeleteAt(QueryString_WADAdboartikel,tempPos,"&")>
TFM_LimitLinksEndCount = 10;
TFM_startLink = Max(1,PageNum_WADAdboartikel - int(TFM_LimitLinksEndCount/2));
TFM_temp = TFM_startLink + TFM_LimitLinksEndCount - 1;
TFM_endLink = min(TFM_temp, TotalPages_WADAdboartikel);
If (TFM_endLink NEQ TFM_temp) {
  TFM_startLink = max(1,TFM_endLink - TFM_LimitLinksEndCount + 1);
<cfoutput query="WADAdboartikel" startRow="#StartRow_WADAdboartikel#" maxRows="#MaxRows_WADAdboartikel#">
    <form action="<cfoutput>#CurrentPage#?#QueryString_WADAdboartikel#</cfoutput>" method="post" onSubmit="this.action=this.action+'&PageNum_WADAdboartikel='+PageNum_WADAdboartikel.value" name="goto">
	<cfif  WADAdboartikel.RecordCount GT MaxRows_WADAdboartikel>
        <div align="center">
        <a href="#" onClick="this.parentNode.submit()" >Go to:</a>
     <!---  <button type="Submit" class="orange"/>Gehe zu Seite:</button> --->
          <input type="text" class="textfieldjump" name="PageNum_WADAdboartikel"  id="PageNum_WADAdboartikel"size="5" />

Open in new window

Pawel WitkowskiSenior Javascript DeveloperCommented:
create it on web .. we dont have coldfusion with your data instaled there..
why are you adding a query string to the action url with this?


this is automatically added to the url onSubmit. I suggest you just remove this statment I think it is your problem.
PanosAuthor Commented:
First of all thank you for your help.
Unfortunately i'm not able to create it on web.
I have "solve" this problem by using css and stylink the button like a link but i want if is possible to find a solution.
I use method post to pass other form values that i don't want in the url, and the variable PageNum_WADAdboartikel to the url.This is the variable i need to show the specific result page i want.
The value is passing with the form too but i don't use that form value but the url value.
I hope i did answer your question GwynforWeb:
PanosAuthor Commented:
I have solved the problem using css and styling a button but i want to have a possible solution using a link and javascript in the form.This code IS working:
      <form action="<cfoutput>#CurrentPage#?#QueryString_WADAdboartikel#</cfoutput>" method="post" onSubmit="this.action=this.action+'&PageNum_WADAdboartikel='+PageNum_WADAdboartikel.value" name="goto">
      <cfif  WADAdboartikel.RecordCount GT MaxRows_WADAdboartikel>
        <div align="center">
        <!--- <a href="#" onClick="document.goto.submit()" >Go to:</a> --->
       <button type="Submit" class="orange"/>
       Go to:</button>
          <input type="text" class="textfieldjump" name="PageNum_WADAdboartikel"  id="PageNum_WADAdboartikel"size="5" />
       <cfif isDefined( 'form.fieldnames' )>
         <cfloop index="thefield" list="#form.fieldnames#">
         <cfif len(trim(form[thefield]))>
         <input type="hidden" name="#thefield#" value="#form[thefield]#" />

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.