PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
RuffRyder
Forum Newbie
Posts: 11 Joined: Thu Apr 08, 2004 7:00 am
Location: Belgium
Post
by RuffRyder » Thu Apr 08, 2004 7:00 am
got a little problem here with my submit button;
i want to use a gif-file as button but it doesn't quite work :s
i used:
Code: Select all
<input type="image" src="images/add.gif" name="toevoegen" value="Add to cart"> but now my products aren't added to the db anymore :s
when i change the type back to "submit" it works perfectly.
can anyone give me some advice of what i'm doing wrong?
grtz
RuffRyder
dipit
Forum Newbie
Posts: 12 Joined: Thu Apr 08, 2004 2:36 am
Location: india
Contact:
Post
by dipit » Thu Apr 08, 2004 7:11 am
try this
<script language="JavaScript">
// Validate
function submitme(form,charfield){
document.<urformName>.submit()
}
AND
<input type="image" src="images/add.gif" name="toevoegen" value="Add to cart" onClick="submitme(this.form,this.name)">
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Thu Apr 08, 2004 7:14 am
You're probably doing if(!empty($_POST['toevoegen'])){ ... } or similar. When you use an image to submit a form then the x & y co-ordinates of the 'button' are submitted, so the easiest way is to check to see if some other element has been posted.
if(!empty($_POST['somefield'])){ ... }
RuffRyder
Forum Newbie
Posts: 11 Joined: Thu Apr 08, 2004 7:00 am
Location: Belgium
Post
by RuffRyder » Thu Apr 08, 2004 7:28 am
i think i've might found the problem, my image button works fine, just when i want to validate when the button is pressed it goes wrong i guess :s
Code: Select all
//my button:
<input type="image" src="images/add.gif" name="toevoegen">
<?
//the validation:
if($_POST['toevoegen']){
$_SESSION['sw'] = 1;
add();
}
//show table with products:
if($_SESSION['sw']==1){
//blahblahblah
i think the problem lies in the $_post var. does anyone know how i can solve this?
thx
Grtz
RuffRyder
RuffRyder
Forum Newbie
Posts: 11 Joined: Thu Apr 08, 2004 7:00 am
Location: Belgium
Post
by RuffRyder » Thu Apr 08, 2004 7:30 am
i thought it would be somethin' like that
thx m8s
budgefeeney
Forum Newbie
Posts: 7 Joined: Tue Apr 06, 2004 9:08 am
Post
by budgefeeney » Thu Apr 08, 2004 7:37 am
I'm a bit of a CSS junky
The active bit means that in Mozilla based browsers the button will change when you click it, so you could have two images, one of a raised button and one ("active") of a depressed button.
Code: Select all
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<style type="text/css">
input.button, input.button:active
{ width: 83px;
height: 28px;
background: url(button.gif) no-repeat;
vertical-align: bottom;
border: 0px none;
cursor: hand;
}
input.button:active
{ background-image: url(button-active.gif);
}
</style>
</head>
<body>
<form action="do-it.php" method="POST">
<p>
<label for="username">User Name:</label>
<input type="text" name="username" id="username">
</p>
<input type="submit" class="button" value="">
</form>
</body>
</html>