...

View Full Version : Submit form by javascript (link)



ofiroth
04-29-2004, 01:09 PM
Hi,
i have a problem with my code.
this is my code:
<SCRIPT>
function Check(MemberItemCode,MemberCode,Store){
document.Formi.method = "POST";
document.Formi.action = "ViewItemMemberNew.asp?MemberItemCode="+MemberItemCode+"&MemberCode="+MemberCode+"&Store="+Store;
document.Formi.submit();
}
</SCRIPT>


<form method="post" name="Formi">
<a href="void(0)" onClick="javascript:Check('154','999999','f0005');">company</a>
</form>

thanks ofir.

requestcode
04-29-2004, 02:37 PM
Could you give us a clue as to what the problem is? Other than missing a double quote at the end of this line:
document.Formi.action = "ViewItemMemberNew.asp?

We can't help unless you give us some more details.

jtaylor
04-30-2004, 05:00 PM
Okay,

It looks to me like what you're trying to do is have this link:

<a href="void(0)" onClick="javascript:Check'154','999999','f0005');">company</a>

dynamically add the values your sending from the onClick. What I don't get is why you're doing it through a function? Unless you're going to be having multiple links on the same page, the function is useless.

If this is the only link on the page, just hard code the link with the values you want sent to the next page, like this:

<A HREF="ViewItemMemberNew.asp?MemberItemCode=154&MemberCode=999999&Store=f0005">

And then from the asp page you can do a Request for the different parts of the url variables and do with them what you will.

I'm having a hard time understanding what the "void(0)" part in the link tag is for? But hope this helps in anyway.

JT

ofiroth
05-03-2004, 09:52 AM
Thanks for the answer,
i have a page with a lot of links. and i want to do one function for all of them.
the problem is that i dont want pepole to see the url link on the address bar so i try to do this with a link that send it like a submit.
i need a function that take parameters from a link and send it to a new page like a submit on a form without to see the parameters on the address bar.
hope that i gave more details now.

glenngv
05-03-2004, 10:20 AM
<script type="text/javascript">
function Check(MemberItemCode,MemberCode,Store){
var f = document.Formi;
f.MemberItemCode.value=MemberItemCode;
f.MemberCode.value=MemberCode;
f.Store.value=Store;
f.submit();
return false;
}
</script>
...
<form method="post" name="Formi" action="ViewItemMemberNew.asp">
<input type="hidden" name="MemberItemCode" />
<input type="hidden" name="MemberCode" />
<input type="hidden" name="Store" />
<a href="#" onclick="return Check('154','999999','f0005');">company</a>
<a href="#" onclick="return Check('155','888888','f0006');">company 2</a>
...
</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum