?
Solved

onmouseover question...

Posted on 2005-05-10
33
Medium Priority
?
402 Views
Last Modified: 2012-08-13
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
Comment
Question by:gchiropoulos
  • 12
  • 11
  • 10
33 Comments
 
LVL 8

Expert Comment

by:NETTY4
ID: 13971180
Like this:

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




0
 
LVL 25

Expert Comment

by:archrajan
ID: 13971183
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
 

Author Comment

by:gchiropoulos
ID: 13971555
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 25

Expert Comment

by:archrajan
ID: 13971590
So ru submitting the form on onmouseover?
0
 

Author Comment

by:gchiropoulos
ID: 13971599
yes I am
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13971629
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
 

Author Comment

by:gchiropoulos
ID: 13971632
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
 
LVL 8

Expert Comment

by:NETTY4
ID: 13971637
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
 

Author Comment

by:gchiropoulos
ID: 13971649
i guess I could use a session variable then toss it when I am done
0
 
LVL 8

Expert Comment

by:NETTY4
ID: 13971650
Oh! beware of multiple forms!!! Why do you need them multiple?
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13971653
may be u shud look into exploring Iframes
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13971672
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
 

Author Comment

by:gchiropoulos
ID: 13971710
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
 

Author Comment

by:gchiropoulos
ID: 13971727
querystring will not work either. I've tried it
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13971738
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
 
LVL 8

Expert Comment

by:NETTY4
ID: 13971757
Show us your submit button. I have an idea for you.
0
 

Author Comment

by:gchiropoulos
ID: 13971815
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
 
LVL 25

Expert Comment

by:archrajan
ID: 13971831
yeah absolutely

thats possible

u can change the action of the form and play around


document.formname.action = 'urfile.asp'
0
 

Author Comment

by:gchiropoulos
ID: 13971832
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
 
LVL 25

Expert Comment

by:archrajan
ID: 13971840
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
 
LVL 25

Assisted Solution

by:archrajan
archrajan earned 1000 total points
ID: 13971857
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
 
LVL 8

Expert Comment

by:NETTY4
ID: 13971874
The select tag will not submit.
0
 

Author Comment

by:gchiropoulos
ID: 13971938
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
 
LVL 25

Expert Comment

by:archrajan
ID: 13972031
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
 

Author Comment

by:gchiropoulos
ID: 13972074
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
 
LVL 25

Expert Comment

by:archrajan
ID: 13972081
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
 
LVL 8

Expert Comment

by:NETTY4
ID: 13972089
Because you missed the () after this.form.submit.

0
 
LVL 8

Expert Comment

by:NETTY4
ID: 13972096
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
 
LVL 25

Expert Comment

by:archrajan
ID: 13972110
thats a typo! to miss ();

u cud have told that instead of just saying the the select tag will not submit ;)
0
 
LVL 8

Expert Comment

by:NETTY4
ID: 13972126
:-)
0
 
LVL 8

Expert Comment

by:NETTY4
ID: 13972138
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
 
LVL 8

Accepted Solution

by:
NETTY4 earned 1000 total points
ID: 13972234
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
 

Author Comment

by:gchiropoulos
ID: 13972809
Finally it works
Thanks guys. You've helped me out of a big jam. I will split the points
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question