Page 1 of 1
javascript and php..
Posted: Fri Sep 01, 2006 8:43 pm
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 ....
Posted: Fri Sep 01, 2006 8:55 pm
by feyd
Well, document.form.submit() isn't correct. And the onclick doesn't need "javascript:" in it.
Posted: Fri Sep 01, 2006 9:19 pm
by Ollie Saunders
yeah its document.form[0].submit()
Posted: Sat Sep 02, 2006 2:39 am
by s.dot
ole wrote:yeah its document.form[0].submit()
document.form
s[0].submit();

Posted: Sat Sep 02, 2006 4:13 am
by timvw
Brr... I find it irritating to see all that javascript mixed up in the html...
http://onlinetools.org/articles/unobtrusivejavascript/.
Posted: Sat Sep 02, 2006 4:28 am
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.
Posted: Sat Sep 02, 2006 7:15 am
by Ollie Saunders
scottayy wrote:ole wrote:yeah its document.form[0].submit()
document.form
s[0].submit();

Right.
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?
Posted: Sat Sep 02, 2006 8:02 am
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
Posted: Sat Sep 02, 2006 9:14 am
by jmut
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">
Posted: Sat Sep 02, 2006 12:32 pm
by ol4pr0
Thanks guys..
wow lots of info .. nice..
Posted: Sat Sep 02, 2006 12:37 pm
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>
Posted: Sat Sep 02, 2006 12:41 pm
by volka
Posted: Sat Sep 02, 2006 12:44 pm
by Ollie Saunders
read up.
form should be pural