Page 1 of 1
Input value and buttons
Posted: Mon Jul 09, 2007 1:05 pm
by Dilbert137
Dear All,
I have made a button save on my script which is inside a form. I have to transfer an input value to a function but the issue is that the button must include the form input text value.
<input class="box" name="btnSave" type="button" id="btnSave" value="Save" onClick="window.location.href='<?php echo $_SERVER['PHP_SELF'] . "?action=save"; ?>';" >
Could you please help me.
Best Regards
Dilbert137
Posted: Mon Jul 09, 2007 1:44 pm
by volka
Couldn't the button just submit the form?
Posted: Tue Jul 10, 2007 12:20 am
by Dilbert137
The form has already a submit input type for update task and the other task like delete, new and save is buttons. Can I make a second submit in a form? Is it possible?
Regards
Dilbert137
Posted: Tue Jul 10, 2007 12:34 am
by jmut
Dilbert137 wrote:The form has already a submit input type for update task and the other task like delete, new and save is buttons. Can I make a second submit in a form? Is it possible?
Regards
Dilbert137
You could have tried it already....just give them diferent name=""/value tag so you know the action required and should be no problem.
Posted: Tue Jul 10, 2007 12:40 am
by Dilbert137
Good.
Posted: Tue Jul 10, 2007 10:54 am
by Dilbert137
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
This is my solution. Maybe it will help some new programmer with the same issue but the case must be equal the value of the submit input value .
Code: Select all
<?php
if (isset($_POST['btnUpdate']))
{
$action=$_POST['btnUpdate'];
}
switch ($action)
{
case 'Update':
updateType();
break;
case 'view':
}
?>
<input class="box" name="btnUpdate" type="submit" id="btnUpdate" value="Update"/>
Best Regards
Dilbert137
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]