Link to home
Start Free TrialLog in
Avatar of gchiropoulos
gchiropoulos

asked on

onmouseover question...

Hello everyone. I have a simple question. I have a very complexe form that I need to have updated one last time so I have tried using onmouseover on the last submit button before the form posts to the database. onmouseover calls a function that does some stuff and it works well WITH THE EXCEPTION:

Once the mouse goes over the submit button it repeatedly calls the function. Is there a way that it only does it one time once the mouse goes over and resets once the mouse leaves the submit button? Basically every time the mouse goes over the input button I would like for it to perform the event only ONCE.

This question is worth 500 points because I am severely STUCK.

Thanks
Avatar of NETTY4
NETTY4

Like this:

<input type=submit name="Submit" value="Submit" onMouseOver="this.onmouseover=null;yourFunction()">




see this simple example:
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
var cnt = 0;
function doit()
{
cnt = cnt +1;
if(cnt <2)
alert('hi')
}
</script>
</HEAD>

<BODY>
<input type = "submit" onmouseover = "doit();">
</BODY>
</HTML>
Avatar of gchiropoulos

ASKER

Both those answers did not work. They work for an alert even but not for a form.submit even. It keeps repeating it since the form resubmits itself. You see the function I am calling posts to itself so the variable is reinitialized.
So ru submitting the form on onmouseover?
yes I am
when u submit the form the page is refreshed...  so is the javascript variables...
all u can do now is use query strings or cookies to keep the count of the onmouseover events..
which is all going to become messy...

why is that ur code submits the form onmouseover?
I am submtting it to itself so that I can use the input box values in the next part of the flow. Basically the onmouseover posts to the same page. asp variable pick up the values on the input boxes and when the actual submit button is clicked it posts to another page. I am stuck using this procedure since I have multiple forms on my page. Is there a way to do it?
Basic thing in http is that http is a stateless protocol.
That does say: one page does not know what page was there before and what will be next page. The server simply send a page after a page was requested by a url. Full Stop.

Now show your page (at least the button with that onMouseOver attribute) and the script for the function what is that evet calling.

i guess I could use a session variable then toss it when I am done
Oh! beware of multiple forms!!! Why do you need them multiple?
may be u shud look into exploring Iframes
yup thats the other way if lookinginto it

if u want to do it with client side javascript
querystring
cookies
and
iframes
are ur options....

but thats gonna make ur code messy!
because I need a form that autoupdates certain elements in a page using a dropdown. The dropdown has a javascript onchange that posts the page to itself using a querystring that is based on the last value selected in the dropdown. The second form is the actual submit form that posts ALL the values on the page to a processing page. So I am stuck using 2 forms. What the onmouseover does is posts the page to itself one last time before posting to the final processing page in case any changes were made on the page. You see, since all my input boxes and such are part of the form that posts to itself, I can't call all the values that were there with request.form from my final processing page since they were not part of the second form.
querystring will not work either. I've tried it
u shud try to use iframes....
may be that cud make ur code more simplified


have the dropdown and that form in the iframe which wud postback and the other form will remain static!
Show us your submit button. I have an idea for you.
What about this.....If I encompass everything on one form it would make everything so much easier. Is there a way to perform a different POST based on 2 buttons in the same form? I am really horrible at Javascript so bear with me. Is it possible to have a form that can post to 2 different pages based on which button is clicked?
yeah absolutely

thats possible

u can change the action of the form and play around


document.formname.action = 'urfile.asp'
Dropdown one could call a function that would POST to page A
and Button two could call a function that would POST to page B?
example:
<input type = "button" value = "yahoo" onclick = "this.form.action = 'http://www.yahoo.com';this.form.submit();">
<input type = "button" value = "google" onclick = "this.form.action = 'http://www.google.com';this.form.submit();">
SOLUTION
Avatar of archrajan
archrajan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The select tag will not submit.
This is what has to be done......

Dropdown onchange has to post back to the same page using the following querystring.
fullfilment.asp?pageview=1&action=<%=action%>&recordID=<%=recordID%>

Button onclick has to post to another page using the following querystring
emailgenerator.asp?pageview=1&action=<%=action%>&recordID=<%=recordID%>&templateID=<%=vartemplateID%>&fromlabel=<%=request.form("fromlabel")%>&subject=<%=request.form("subjectlabel")%>&extramessage=<%=messagelabel%>

So what do I do? Call a function onchange for the dropdown and onclick for the button and what does that function look like? And what does the form tag look like???
why will a select tag not submit???

it wud for sure

check this

<form action = "http://www.google.com">
<select onchange = "this.form.submit();">
<option>1</option>
<option>w</option>
</select>
</form>
Arch I think it may work like that if I could insert an asp variable between 'uraction'. Is there a specific way to do it? I tried
<input type = "button" value = "submit form" onclick = "this.form.action = <%=aspvariable%>;this.form.submit();">

and it didnt' work
this is ur select tag


<select name = "urselbox" onchange = "this.form.action = 'fullfilment.asp?pageview=1&action='+<%=action%>+'&recordID='+<%=recordID%>;this.form.submit();">


and
this is ur button

<input type = "button" value = "submit form" onclick = "doit(this);">


function dothis(obj)
{
var temp =
"emailgenerator.asp?pageview=1&action="+<%=action%>+"&recordID="+<%=recordID%>+"&templateID="+<%=vartemplateID%>+"&fromlabel="+<%=request.form("fromlabel")%>+"&subject="+<%=request.form("subjectlabel")%>+"&extramessage="+<%=messagelabel%>

obj.form.action = temp;
obj.form.submit();
}
Because you missed the () after this.form.submit.

And this is valid ASP syntax:


<select name = "urselbox" onchange = "this.form.action = 'fullfilment.asp?pageview=1&action=<%=action%>&recordID=<%=recordID%>';this.form.submit();">



thats a typo! to miss ();

u cud have told that instead of just saying the the select tag will not submit ;)
:-)
Now the question is still how to hit the button on mouse over (which is still an absolute nonsense in my opinion) and I could show you the ASP for that combination. Still working on that mouseover submit(;-)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Finally it works
Thanks guys. You've helped me out of a big jam. I will split the points