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" />
</form>

Open in new window

LVL 2
PanosAsked:
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:

do:

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



instead of:

<a href="#" onClick="document.goto.submit()" >Go to:</a>
0
PanosAuthor Commented:
Hi
It is not working
0
GwynforWebCommented:
       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.
0
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 ?:)
0
PanosAuthor Commented:
Ok.
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
<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
ORDER by art_ID ASC
</cfquery>
<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,"&")>
</cfif>
<cfscript>
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);
}
</cfscript>
</head>
 
<body>
<table>
<cfoutput query="WADAdboartikel" startRow="#StartRow_WADAdboartikel#" maxRows="#MaxRows_WADAdboartikel#">
  <tr>
    <td>#Wadadboartikel.Art_ID#</td>
    <td>#Wadadboartikel.Price#</td>
  </tr>
  </cfoutput>
</table>
 
    <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" />
   </div>
   </cfif> 
    </form>
 
</body>
</html>

Open in new window

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

onSubmit="this.action=this.action+'&PageNum_WADAdboartikel='+PageNum_WADAdboartikel.value"

this is automatically added to the url onSubmit. I suggest you just remove this statment I think it is your problem.
0
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:
0
PanosAuthor Commented:
Hello.
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' )>
        <cfoutput>
         <cfloop index="thefield" list="#form.fieldnames#">
         <cfif len(trim(form[thefield]))>
         <input type="hidden" name="#thefield#" value="#form[thefield]#" />
         </cfif>
         </cfloop>
        </cfoutput>
       </cfif>
   </div>
   </cfif>
    </form>
0

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
JavaScript

From novice to tech pro — start learning today.