Click to See Complete Forum and Search --> : Script Request


jraper
05-12-2003, 10:03 PM
I have a form in a shopping cart I'm developing. I want to make a Quanity text box change to 0 when a user clicks a check box. Is this possible?

Greelmo
05-12-2003, 10:07 PM
just make a java function called with an "onclick" from the button "check mark"

Greelmo
05-12-2003, 10:15 PM
sorry, that prolly didn't help much... i think this will work...
<SCRIPT LANGUAGE = "JavaScript">
function fncname()
{
document.(name of form that the thing you want to be "0" is in).(name of thing you want to be "0".value = "0";
}
</script>

then... the button should be...
<input type = "button" value = "(what button should read)" onclick = "JavaScript: fncname();">

Jona
05-12-2003, 11:17 PM
Greelmo, close, but not quite. You don't need the Javascript: part.

<script language="javascript" type="text/javascript">
function functionName(butn){butn.value = "0"; }
</script>
<form name="formName" action=""><div>
<input type="button" value="This will be zero when you click it" onclick="functionName(this);">
</div></form>

Greelmo
05-12-2003, 11:32 PM
okay, i see what you did... would it work at all the way i did it though?

Jona
05-12-2003, 11:36 PM
No, it wouldn't work. Javascript: is only used for anchors (links) and nothing else. And javascript: is also not capitalized. And, the code I posted is valid HTML 4.01 Transitional, but I didn't completely include headers, the DTD or the HTML starting tags (nor did I include the BODY tag); this is because it was a mere example. If the code I posted were put in a document with a DTD, HTML, title, HEAD, META (charset, content-types), and a BODY, it would be valid HTML 4.01 Transitional--as a matter of fact, it would also probably be valid HTML 4.01 Strict, too, although I'm not sure.