jussa
10-02-2006, 12:18 AM
ok, i have a button on my page, and everytime i want to click to it, it goes to post data...but i want it to only perform a script, not actually post any data...
<input type="submit" value="Show Grins" onClick="chngGrinStyle();return false;">
how i prevent it from posting data?
Thanks, Justin
_Aerospace_Eng_
10-02-2006, 12:33 AM
Get rid of that onclick. Add return false as the last line of the chngGrinStyle() function. Then in the open form tag add
onsubmit="return chngGrinStyle()"
If done correctly the form should just run the script and not post anything.
jussa
10-02-2006, 01:26 AM
Hi, that didnt seem to work...
this is now my button code..
<input type="submit" value="Show Grins" onsubmit="return chngGrinStyle()">
and this is my js...
function chngGrinStyle() {
objDiv = document.getElementById('wp_grins2');
if (objDiv.style.display == "none") {
objdiv.style.display == "block";
} else {
objDiv.style.display == "none";
}
return false;
}
and that sits in a seperate js file...but i know the path of the js file works, coz if i plug it into the address bar...i can dl it..
it still goes to post the data...
Thanks, Justin
felgall
10-02-2006, 01:32 AM
<input type="submit"> is a button that submits the form (anything else is secondary.
<input type=button"> is a button that does what you ask it to do and has no default action
<button></button> can be used to create a button outside of a form
_Aerospace_Eng_
10-02-2006, 01:44 AM
I don't think you read my post too carefully. Do you not have a form tag? I said put onsubmit IN the form tag NOT the input button.