form submit not working - Javascript
This is a discussion on form submit not working - Javascript ; Hi ther:
i m pretty sure I m forgetting somthing stupid but i cant make this
work
any ideas?
<form id="searchPartForm" method="get" action="index.php">
<label for="search">Find : </label>
<input id="searchpart" type="text" value="" name="searchpart"/>
<a href="javascript :submitform()" class="lbAction"
rel="insert">Search</a>
</form>
<script type="text/javascript">
...
-
form submit not working
Hi ther:
i m pretty sure I m forgetting somthing stupid but i cant make this
work
any ideas?
<form id="searchPartForm" method="get" action="index.php">
<label for="search">Find : </label>
<input id="searchpart" type="text" value="" name="searchpart"/>
<a href="javascript:submitform()" class="lbAction"
rel="insert">Search</a>
</form>
<script type="text/javascript">
function submitform()
{
document.searchPartForm.submit();
}
</script>
Thanks
-
Re: form submit not working
roundcrisis wrote on 13 aug 2007 in comp.lang.javascript:
> i m pretty sure I m forgetting somthing stupid but i cant make this
> work
> any ideas?
> <form id="searchPartForm" method="get" action="index.php">
Does index.php exist?
> <label for="search">Find : </label>
Where does "search" point to?
> <input id="searchpart" type="text" value="" name="searchpart"/>
Why do you use /> i.s.o. just >?
> <a href="javascript:submitform()" class="lbAction"
> rel="insert">Search</a>
Where are you using the rel= for?
> </form>
> <script type="text/javascript">
> function submitform()
> {
> document.searchPartForm.submit();
Why don't you use [cross browser minded]:
document.forms['searchPartForm'].submit();
or
document.getElementById('searchPartForm').submit();
>}
> </script>
Wat does does not work mean?
Do you get a new window?
What is ther address bar content?
Do you get an error?
What is the error text?
What Browser are you using?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
-
Re: form submit not working
On 13 Aug, 20:15, roundcrisis <roundcri...> wrote:
> Hi ther:
>
> i m pretty sure I m forgetting somthing stupid but i cant make this
> work
> any ideas?
>
> <form id="searchPartForm" method="get" action="index.php">
> <label for="search">Find : </label>
> <input id="searchpart" type="text" value="" name="searchpart"/>
> <a href="javascript:submitform()" class="lbAction"
> rel="insert">Search</a>
> </form>
> <script type="text/javascript">
> function submitform()
> {
> document.searchPartForm.submit();}
>
> </script>
>
> Thanks
I think you need to add name="searchPartForm" on the form tag, but I'm
not 100% sure
-
Re: form submit not working
ok its worse that I though
This script was runing inside a lightbox (http://particletree.com/
features/lightbox-gone-wild/)`
and the problem is that when i try to do a search from a form i go to
this part of the code:
-------------------------------
insert: function(e){
link = e.target;
Element.remove($('lbContent'));
var myAjax = new Ajax.Request(
link.href,
{method: 'post', parameters: "", onComplete:
this.processInfo.bindAsEventListener(this)}
);
------------------------------
at the moment the line taht includes link.href, runs the value of
link.href is
"javascript:document.getElementById('searchPartForm').submit();"
not good uhh?
I can get the actual address that I want to open from
Event.element(e).parentNode.action and the parameters from
Event.element(e).parentNode.[parametername]
but how do i do it so it is generic
ie
when its not a form this happens link = e.target;
when its a form get the necesary values
any help would eb greatly apreciated 
-
Re: form submit not working
On Aug 13, 3:18 pm, roundcrisis <roundcri...> wrote:
> ok its worse that I though
> This script was runing inside a lightbox (http://particletree.com/
> features/lightbox-gone-wild/)`
>
> and the problem is that when i try to do a search from a form i go to
> this part of the code:
> -------------------------------
> insert: function(e){
>
> link = e.target;
>
> Element.remove($('lbContent'));
>
> var myAjax = new Ajax.Request(
> link.href,
> {method: 'post', parameters: "", onComplete:
> this.processInfo.bindAsEventListener(this)}
> );
>
> ------------------------------
> at the moment the line taht includes link.href, runs the value of
> link.href is
> "javascript:document.getElementById('searchPartForm').submit();"
> not good uhh?
>
> I can get the actual address that I want to open from
> Event.element(e).parentNode.action and the parameters from
> Event.element(e).parentNode.[parametername]
> but how do i do it so it is generic
> ie
> when its not a form this happens link = e.target;
> when its a form get the necesary values
>
> any help would eb greatly apreciated 
well ok I fixed it but I m sure its not in the best way so I d
apreciate the input or suggestions
----------------------
insert: function(e){
link = e.target;
if (Event.element(e).parentNode.tagName == "FORM"){
parameterString="?";
for(i=0; i< Event.element(e).parentNode.elements.length; i++)
{
parameterString =parameterString
+Event.element(e).parentNode.elements[i].id
+"="+Event.element(e).parentNode.elements[i].value+"&";
}
link.href=Event.element(e).parentNode.action+parameterString;
}
Element.remove($('lbContent'));
----------------------
Cheers
Similar Threads
-
By Application Development in forum DOTNET
Replies: 5
Last Post: 12-12-2007, 06:33 PM
-
By Application Development in forum Perl
Replies: 5
Last Post: 09-17-2007, 12:24 PM
-
By Application Development in forum Adobe Acrobat
Replies: 5
Last Post: 06-25-2007, 11:11 PM
-
By Application Development in forum Javascript
Replies: 3
Last Post: 06-23-2007, 02:29 AM
-
By Application Development in forum Javascript
Replies: 0
Last Post: 04-18-2005, 10:25 AM