Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Submit HREF help!

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
tport_rti
Asked:
tport_rti
  • 4
  • 4
  • 2
2 Solutions
 
Tomarse111Commented:
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
 
Tomarse111Commented:
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
 
tport_rtiAuthor Commented:
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
Industry Leaders: 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!

 
Tomarse111Commented:
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
 
tport_rtiAuthor Commented:
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
 
Tomarse111Commented:
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
 
hieloCommented:
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
 
tport_rtiAuthor Commented:
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
 
hieloCommented:
>>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
 
tport_rtiAuthor Commented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now