• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 429
  • Last Modified:

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
0
gchiropoulos
Asked:
gchiropoulos
  • 12
  • 11
  • 10
2 Solutions
 
NETTY4Commented:
Like this:

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




0
 
archrajanCommented:
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>
0
 
gchiropoulosAuthor Commented:
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
archrajanCommented:
So ru submitting the form on onmouseover?
0
 
gchiropoulosAuthor Commented:
yes I am
0
 
archrajanCommented:
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?
0
 
gchiropoulosAuthor Commented:
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?
0
 
NETTY4Commented:
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.

0
 
gchiropoulosAuthor Commented:
i guess I could use a session variable then toss it when I am done
0
 
NETTY4Commented:
Oh! beware of multiple forms!!! Why do you need them multiple?
0
 
archrajanCommented:
may be u shud look into exploring Iframes
0
 
archrajanCommented:
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!
0
 
gchiropoulosAuthor Commented:
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.
0
 
gchiropoulosAuthor Commented:
querystring will not work either. I've tried it
0
 
archrajanCommented:
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!
0
 
NETTY4Commented:
Show us your submit button. I have an idea for you.
0
 
gchiropoulosAuthor Commented:
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?
0
 
archrajanCommented:
yeah absolutely

thats possible

u can change the action of the form and play around


document.formname.action = 'urfile.asp'
0
 
gchiropoulosAuthor Commented:
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?
0
 
archrajanCommented:
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();">
0
 
archrajanCommented:
yeah just in the drop down

<select name = "sel" onchange = "this.form.action = 'uraction';this.form.submit">

and

<input type = "button" value = "submit form" onclick = "this.form.action = 'uraction';this.form.submit();">
0
 
NETTY4Commented:
The select tag will not submit.
0
 
gchiropoulosAuthor Commented:
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???
0
 
archrajanCommented:
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>
0
 
gchiropoulosAuthor Commented:
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
0
 
archrajanCommented:
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();
}
0
 
NETTY4Commented:
Because you missed the () after this.form.submit.

0
 
NETTY4Commented:
And this is valid ASP syntax:


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



0
 
archrajanCommented:
thats a typo! to miss ();

u cud have told that instead of just saying the the select tag will not submit ;)
0
 
NETTY4Commented:
:-)
0
 
NETTY4Commented:
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(;-)
0
 
NETTY4Commented:
Ok, here theASP code for the button with onMouseOver click once trigger:

<input type=submit name="Submit" value="Submit"  onMouseOver="this.onmouseover=null;this.form.action='emailgenerator.asp?pageview=1&action=<%=action%>&recordID=<%=recordID%>&templateID=<%=vartemplateID%>&fromlabel=<%=request.form("fromlabel")%>&subject=<%=request.form("subjectlabel")%>&extramessage=<%=messagelabel%>';this.click()">

While the form is submitting you should not change the select option.
If you like to build also a protection for that exception, then you need an additional hidden field.
But I think that would be an overkill.


0
 
gchiropoulosAuthor Commented:
Finally it works
Thanks guys. You've helped me out of a big jam. I will split the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 12
  • 11
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now