Hi everybody. I have a little problem.
Is there any way to modify standard html form buttons with php, or to create a new button?
Thanks
Hi everybody. I have a little problem.
Is there any way to modify standard html form buttons with php, or to create a new button?
Thanks
hi vicent (for a second i thought it was vincent, but than i read the question ),
PHP is a ServerSide Scripting Language, so there is no way to create Form Buttons, of course you can use a image as a button, but that is a JavaScript Task ...
To modify a Form Button isn't that hard ... but I think you are allready aware of the possibility to change the buttons name or caption via PHP ...
You can also use PHP to generate images and use them for buttons, but again this goes to JS ... There is a way to use a image as a button, without need for JS ... but you have no "rollOver" Status if you use this solution ... it goes sort like <INPUT TYPE="IMAGE" or similar ... not quite sure, but it is somewhere in the PHP Manual ... (I think the part with "Variables from Outside PHP" but again, not sure about this ...)
hope that helps
cya Rob
You can try something like:
<script language="JavaScript">
<!--
function validEntry(){
if (document.my_form.my_field.value == ''){
alert('You've got to enter something!');
document.my_form.my_field.focus();
}else{
document.my_form.submit();
}
}
//-->
</script>
<body>
<form name="my_form" action="my_script.php" method="POST">
<input type="text" name="my_field">
<img scr="/path/to/imgbutton.jpg" onClick="javascript: validEntry();">
</form>
</body>
Now there might be some errors in there, cause I did this on the fly, but it should be pretty close. Be sure make it work on both Netscape and IE.
Take a couple of JavaScript tutorials that are around the web to help you get your feet wet with this skill. Plus you can get good ideas from looking at other pages source code.
Good Luck,
t