Topic: compliant form without an action? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=23832" title="Pages that link to Topic: compliant form without an action? (Page 1 of 1)" rel="nofollow" >Topic: compliant form without an action? <span class="small">(Page 1 of 1)</span>\

 
ninmonkeys
Nervous Wreck (II) Inmate

From:
Insane since: May 2004

posted posted 10-27-2004 21:57

I'm trying to make a form similar to the one on this page that lets you draw a line http://nyphp.org/content/presentations/GDintro/gd10.php

Is there a "fake" type action I can use? (example for a link you can use <a href="#">link</a> )

I don't want the page to reload when the button is clicked, it should just change the image's source using the form input.

This code works, but does not validate since my form has no "action"

code:
<script type="text/javascript">
<!--
function updateLine(data)
{
//update image with new values
document.images.imageLine.src = 'images/drawline.php?x1=' +
data.x1.value + '&y1=' + data.y1.value + '&x2=' +
data.x2.value + '&y2=' + data.y2.value;
}
-->
</script>

<!-- ... code ... -->

<form method="post" id="line">
<p>x1:<input type="text" id="x1" value="1" size="3" maxlength="3" />,
y1:<input type="text" id="y1" value="1" size="3" maxlength="3" />,
x2:<input type="text" id="x2" value="50" size="3" maxlength="3" />,
y2:<input type="text" id="y2" value="10" size="3" maxlength="3" />
</p><p><input onclick="javascript:updateLine(this.form);" type="button" id="bLineRedraw" value="redraw">
</p>
</form>

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 10-27-2004 22:37

Just let the action attribute blank, and cancel the submit of the form via :

code:
<form method="post" id="line" action="" onsubmit="return false">

BTW, there's no need to precise the javascript: protocol in the events since the events are of the type %Script; in the DTD

Hope that helps,

ninmonkeys
Nervous Wreck (II) Inmate

From:
Insane since: May 2004

posted posted 10-28-2004 00:55
quote:
poi said:

BTW, there's no need to precise the javascript: protocol in the events since the events are of the type %Script; in the DTD

Cool, thanks for the info.

It validates now



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu