javascript and php..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

javascript and php..

Post by ol4pr0 »

ok trying to pass a url for form submit.. but nothing happening..

Code: Select all

<script language="javascript">
function submitform(url)
{
  document.form.submit(url);
}
</script>

Code: Select all

<form action="#" method="POST">
<input type="image" src="images/unpublish.png" height="18" name="publish" onclick="javascript:submitform(<?php echo $globals->replace($_REQUEST['a'],"active",$_SERVER['REQUEST_URI']);?>)" value="0"></input>
</form>
Whats wrong ....
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Well, document.form.submit() isn't correct. And the onclick doesn't need "javascript:" in it.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

yeah its document.form[0].submit()
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

ole wrote:yeah its document.form[0].submit()
document.forms[0].submit(); ;)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Brr... I find it irritating to see all that javascript mixed up in the html... http://onlinetools.org/articles/unobtrusivejavascript/.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

feyd wrote:Well, document.form.submit() isn't correct. And the onclick doesn't need "javascript:" in it.
yes it does need it.
unless you have meta tag saying you use javascript.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

scottayy wrote:
ole wrote:yeah its document.form[0].submit()
document.forms[0].submit(); ;)
Right. :oops:
yes it does need it.
unless you have meta tag saying you use javascript.
I've never used it. What would that meta tag look like?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ole wrote:I've never used it. What would that meta tag look like?
He's referring to this, which I have never cared about.

http://www.w3.org/TR/html4/interact/scr ... ult-script
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

feyd wrote:
ole wrote:I've never used it. What would that meta tag look like?
He's referring to this, which I have never cared about.

http://www.w3.org/TR/html4/interact/scr ... ult-script
well, I guess it will never hurt really because I suppose browser by default assume javascript but still...

this on top never hurts :)

Code: Select all

<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Thanks guys..

wow lots of info .. nice..
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

However not working


changed the document.form[0].submit(url)

and also tried taking off the javascript part from the :submit(the.php.echo)

But no luck..

its submitting but its not passing trough the url ... am i missing somethign else here.
the other problem is that the post variables arent actually changing.. just the button..

the form code looks like this.

Code: Select all

<th scope="col" width="10px;"><? echo $row->login; ?></th>
		<th scope="col" width="20px;"><? echo $row->level; ?></th>
		<th scope="col" width="50px;"><? echo $row->active; ?></th>
		<th scope="col" width="10px;"><? echo $row->lastlogin; ?></th>
		<th scope="col" width="10px;">
		<input type="image" src="images/edit.png" width="22" height="22" border="0" name="edit" onclick="javascript:submitform(<?php echo $globals->replace($_REQUEST['a'],"active",$_SERVER['REQUEST_URI']);?>)"></input>
		<input type="hidden" value="<? echo $row->id; ?>" name="u"></input>
		</th>
		<th scope="col" width="10px;">
		<?
		if ($row->active == true) {?>
		<input type="image" src="images/unpublish.png" height="18" name="publish" onclick="submitform(<?php echo $globals->replace($_REQUEST['a'],"active",$_SERVER['REQUEST_URI']);?>)"></input>
		<input type="hidden" name="active" value="0"></input>
		<input type="hidden" value="<? echo $row->id; ?>" name="u"></input>
		<?} else {?>
		<input type="image" src="images/publish.png" height="18" name="publish" onclick="submitform('<?php echo $globals->replace($_REQUEST['a'],"delete",$_SERVER['REQUEST_URI']);?>')"></input>
		<input type="hidden" name="active" value="1"></input>
		<input type="hidden" value="<? echo $row->id; ?>" name="u"></input>
Last edited by ol4pr0 on Sat Sep 02, 2006 12:47 pm, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

according to http://www.w3.org/TR/DOM-Level-2-HTML/h ... D-40002357 submit() doesn't accept parameters.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

read up.
form should be pural
Post Reply