Input value and buttons

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Dilbert137
Forum Commoner
Posts: 57
Joined: Sat Jun 02, 2007 5:02 am
Location: Mauritius

Input value and buttons

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Couldn't the button just submit the form?
Dilbert137
Forum Commoner
Posts: 57
Joined: Sat Jun 02, 2007 5:02 am
Location: Mauritius

Post 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
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post 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.
Dilbert137
Forum Commoner
Posts: 57
Joined: Sat Jun 02, 2007 5:02 am
Location: Mauritius

Post by Dilbert137 »

Good.
Dilbert137
Forum Commoner
Posts: 57
Joined: Sat Jun 02, 2007 5:02 am
Location: Mauritius

Post by Dilbert137 »

feyd | Please use

Code: Select all

,

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

,

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]
Post Reply