Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Submit HREF help!

Posted on 2008-10-27
10
Medium Priority
?
426 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 1000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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 1000 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

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!

Question has a verified solution.

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

What You Need to Know when Searching for a Webhost Provider
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
Suggested Courses

971 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