Solved

Submit HREF help!

Posted on 2008-10-27
10
410 Views
Last Modified: 2013-12-24
I am sure this has been asked 1,000,000 times. It is a tired question. That said I still can't find the answer I'm looking for...

I'm trying to submit a page using a href and nothing I do submits it. I have tried so many things I'm now so confused I'm of no use!

Here's snippets of the form... I have a link to save in the middle of the form b/c it's such a long form. Therefore I also have THREE submit buttons.


<head>

<SCRIPT LANGUAGE="JAVASCRIPT">

// I'm including this function in case this could be causing the problem 

		function checkLength(form){

		if (addFrm.comments.value.length > 5000){

		alert("Please limit comments to 5000 characters.");

		return false;

		}

		if (addFrm.summary.value.length > 20){

		alert("Please limit comments to 5000 characters.");

		return false;

		}

		return true;

		}

</SCRIPT>
 

<style><!--- this is just a portion of my .css but it's the part that contains the style for this td ---> 

}

a.TopRightAnchor_Save:link, a.TopRightAnchor_Save:visited {

	background-image: url(../images/Btn_Save.gif);

}

a.TopRightAnchor_Save:hover {

	text-decoration: none;

	background: url(../images/Btn_Save_OVER.gif) no-repeat;

	border: 1px dashed #777;

}

</style>

</head>
 

<form method="post" action="act_submitReport.cfm" name="addFrm" id="addFrm"  passthrough ="HTML_attributes" enctype="multipart/form-data" onSubmit="return checkLength(this)">
 

...bunch of fields... 
 

 <link I need to submit - I do not have any submit code in here right now b/c nothing I tried works, but I tried various onClick Submit functions>

<td><a class="TopRightAnchor_Save" style="float: right; margin-left: 0;" href="">Save</a></td>
 

<input type="submit" value=Submit">&nbsp;<input type="submit" value="Save">

</form>

Open in new window

0
Comment
Question by:tport_rti
  • 4
  • 4
  • 2
10 Comments
 
LVL 15

Expert Comment

by:Tomarse111
ID: 22814211
Change your href to read:

should do the trick :)
<a class="TopRightAnchor_Save" style="float: right; margin-left: 0;" href="javascript:void(0);" onclick="document.addFrm.submit();">Save</a>

Open in new window

0
 
LVL 15

Accepted Solution

by:
Tomarse111 earned 250 total points
ID: 22814348
Of if you want it to fire off your checkLength function first then submit from the <a> tag do, change your function to the below and add the new <a> tag in:
<SCRIPT LANGUAGE="JAVASCRIPT">

	function checkLength(form){				

		if (document.addFrm.comments.value.length > 5000){

			alert("Please limit comments to 5000 characters.");

			return false;

		}

		if (document.addFrm.summary.value.length > 20){

			alert("Please limit comments to 5000 characters.");

			return false;

		}					

		document.addFrm.submit();

	}

</SCRIPT>
 

<a class="TopRightAnchor_Save" style="float: right; margin-left: 0;" href="javascript:void(0);" onclick="return checkLength()">Save</a>

Open in new window

0
 

Author Comment

by:tport_rti
ID: 22814352
Thanks... You would think that would work... I've tried that and other variations... I get an error:
Line: 374
Char: 1
Error: Object doesn't support this method or property.
Code: 0
I do not know why. I have a lot of other javascript in the form... but when I take this out I don't have any errors.
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 22814384
What browser are you using? I've tested the above in FF3 and IE7 and it works fine. Did you try the second example I gave?

You could change the document.form.element to getElementById's to see if that works?
0
 

Author Comment

by:tport_rti
ID: 22814412
IE 7...
 
Could the other javascript I have in here be blowing it up? I have a ton...
 in one section:
 


 

<tr>

     <th class="ON" id="firstTab" style="border-left: 1px;"><a HREF="javascript:void(0)" name="contact" onClick="setActiveTab(this.parentNode); hideAll(); changeDiv('contact1','block');"><strong>Primary Contact</strong></a> </th>

      <th class="OFF"><a HREF="javascript:void(0)" name="contact" onClick="setActiveTab(this.parentNode); hideAll(); changeDiv('contact2','block');"><strong>Contact 2</strong></a> </th>

      <th class="OFF"><a HREF="javascript:void(0)" name="contact" onClick="setActiveTab(this.parentNode); hideAll(); changeDiv('contact3','block');"><strong>Contact 3</strong></a> </th>

      <th class="OFF"><a HREF="javascript:void(0)" name="contact" onClick="setActiveTab(this.parentNode); hideAll(); changeDiv('contact4','block');"><strong>Contact 4</strong></a> </th>

      <th class="OFF"><a HREF="javascript:void(0)" name="contact" onClick="setActiveTab(this.parentNode); hideAll(); changeDiv('contact5','block');"><strong>Contact 5</strong></a> </th>

     </tr> 
 

  and in an include with a bunch of other functions... 
 
 

  function confirmSubmit()

  {

  var agree=confirm("Click [OK] to continue without saving or [CANCEL] to exit request and save.");

  if (agree)

   return true ;

  else

   return false ;

  }

  function popUp(URL) {

  day = new Date();

  id = day.getTime();

  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=420,height=200,left = 362,top = 234');");

  }

  

  function confirmSubmit2()

  {

  var agree=confirm("This follow-up has been saved in the system. \n Please save your work before removing a previously saved follow-up. \n Click [OK] to continue or [CANCEL] to exit request and save.");

  if (agree)

   return true ;

  else

   return false ;

  }

  

  function confirmSubmit3()

  {

  var agree=confirm("This link has been saved in the system. \n Please save your work before removing a previously saved follow-up. \n Click [OK] to continue or [CANCEL] to exit request and save.");

  if (agree)

   return true ;

  else

   return false ;

  }

  

  function confirmSubmit4()

  {

  var agree=confirm("This upload has been saved in the system. \n Please save your work before removing a previously saved follow-up. \n Click [OK] to continue or [CANCEL] to exit request and save.");

  if (agree)

   return true ;

  else

   return false ;

  }

  function ShowDiv(id) 

  {

   if (document.getElementById(id))

   {

    document.getElementById(id).style.display = 'block';

   }

  }

  

  function HideDiv(id) 

  {

   if (document.getElementById(id))

   {

     document.getElementById(id).style.display = 'none';

   }

  }   

  

  function ShowHideDiv(id) 

  {

   obj = document.getElementsByTagName("div");

  //alert ("got to showHide - " + id + " - "  + buttonName + " - "  + group);

   if (obj[id].style.display == 'block')

   {

    HideDiv(id);

   }

   else

   {

      ShowDiv(id);

   }

  }  

Open in new window

0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 15

Expert Comment

by:Tomarse111
ID: 22814498
hmmm if its just this function that is erroring just the amended one below (adding the actual id's to your form elements of course). and then doing the href and onclick from my second example above:
function checkLength(){				

		if (document.getElementById('comments').value.length > 5000){

			alert("Please limit comments to 5000 characters.");

			return false;

		}

		if (document.getElementById('summary').value.length > 20){

			alert("Please limit comments to 5000 characters.");

			return false;

		}	

		document.addFrm.submit();

	}

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 22814608
your function expects a form object. Try:
<td><a class="TopRightAnchor_Save" style="float: right; margin-left: 0;" href="#" onclick="if( checkLength( document.getElementById('addFrm') ) ){ document.getElementById('addFrm').submit(); }">Save</a></td> 
IMPORTANT: make sure there is NO element with 
id="submit" and/or name="submit". If there is, you need to change the id and/or name.

Open in new window

0
 

Author Comment

by:tport_rti
ID: 22814689
I have an input further down that is a submit - two in fact. I need to this save in the middle of the page b/c - well, the user requested it - but also it's a long form. So which name would I change? If I change the actual input submit, they won't submit... no?
 
<input type="submit" value=Submit">&nbsp;<input type="submit" value="Save">
 
 
0
 
LVL 82

Assisted Solution

by:hielo
hielo earned 250 total points
ID: 22814799
>>I have an input further down that is a submit - two in fact
Yes, I noticed. But I did NOT say
change type='submit'

I said:
Make sure that you do NOT have anything with id="submit" and/or name="submit". You can have:

<input type="submit" name="theSubmit" value="Submit"/>
 

You can even have:

<input type="submit" name="Submit" value="Submit"/>
 

(upper case "S" for name="Submit"), as long as it is NOT lower case "s":

<input type="submit" name="submit" value="Submit"/>

Open in new window

0
 

Author Closing Comment

by:tport_rti
ID: 31510389
Still doesn't work for me but it appears to be something in my additonal code. Hope you don't mind I split the points between you two. Thank you for toughing it out with me!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can display objects ? 3 20
Add Context Menu Item 4 43
Don't understand jquery promises 6 36
How to change pointer icon to hand icon on mouseover 2 17
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now