form submit not working

R

roundcrisis

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
 
E

Evertjan.

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?
 
D

daniel.westerberg

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
 
R

roundcrisis

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 :D
 
R

roundcrisis

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 :D

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.id
+"="+Event.element(e).parentNode.elements.value+"&";
}
link.href=Event.element(e).parentNode.action+parameterString;
}
Element.remove($('lbContent'));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top