Home Forums Gamescan Chat42 About
* Login   * Register * FAQ    * Search
It is currently Tue 12-30-2025 5:22PM

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: run a javasciprit function
PostPosted: Sun 02-12-2006 8:29PM 
Offline
Major
User avatar

Joined: Mon 08-16-2004 3:52PM
Posts: 289

Source: TJ South
Hey everyone. I'd like to know how to run a javascipt function. I'm wanting to use javascript to submit a form. here's how I want to do it:

<form name="myform" action="handle-data.php">
Search: <input type='text' name='query'>
<A href="javascript: submitform()">
<img src="go.gif" width="33" height="19" border="0">
</A>
</form>
<SCRIPT language="JavaScript1.2">
function submitform()
{
if(document.myform.onsubmit())
{
document.myform.submit();
}
}
</SCRIPT>


I just want to run the submitform() function. I don't want the user to have to do anything. It loads the page, and then runs the functions. Any Ideas?

-gw


Top
 Profile E-mail  
    
 Post subject:
PostPosted: Tue 02-14-2006 12:10AM 
Offline
Major
User avatar

Joined: Mon 08-16-2004 3:52PM
Posts: 289

Source: TJ South
nevermind. Found out how to do it. you can run it from the body tag:

<body onLoad=" function();">

Hope that helps someone.

-gw


Top
 Profile E-mail  
    
 Post subject:
PostPosted: Fri 03-03-2006 10:28AM 
Offline
Cookie Monster
Cookie Monster
User avatar

Joined: Mon 05-12-2003 6:27PM
Posts: 423
Location: Rolla

Source: Off Campus
hopefully you are putting your javascript functions between the HEADER tags.


Top
 Profile  
    
 Post subject:
PostPosted: Fri 03-03-2006 12:40PM 
Offline
Major
User avatar

Joined: Mon 08-16-2004 3:52PM
Posts: 289

Source: Wilson Library
yeah, I was. put any and all code before the body tag. Like if you want the javascript to submit for you, then you need to add in the form information before the body

<form action="somehwere.html" method="post">
<input type="hidden" name="whatever" value="<? echo $php_var?>" >
</form>

or what ever else you needed. Why do it this way and not simply use a submit button?? this allowed me to submit information to two pages automaticly. the first page was sumbited when the user click. Then the second page was submited automaticly by the java script. Hope that helps!

-gw


Top
 Profile E-mail  
    
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group