Link to home
Start Free TrialLog in
Avatar of Panos
PanosFlag for Germany

asked on

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

Avatar of Pawel Witkowski
Pawel Witkowski
Flag of Poland image

have you tried:

do:

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



instead of:

<a href="#" onClick="document.goto.submit()" >Go to:</a>
Avatar of Panos

ASKER

Hi
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.
help us help you :) can you add some example page for that problem ?:)
Avatar of Panos

ASKER

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

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?

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.
Avatar of Panos

ASKER

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:
ASKER CERTIFIED SOLUTION
Avatar of Panos
Panos
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial