Jump to content

Action depending on drop down


gnawz

Recommended Posts

Hi

 

I have a drop down thus

 

 

<form name = frmUtils method = POSTaction = "">

<select name = Do>

<option>Add</option>

<option>Delete</option>

<option>Update</option>

</select>

</form>

 

I want the form action to change based on the selection ie

 

if selected Index is Add

action = add.php

 

 

if selected Index is Delete

action = delete.php

 

 

if selected Updateis Add

action = update.php

 

Somebody help

 

 

Link to comment
Share on other sites

Note: The code is not tested be aware of that...

 

 

<script type="text/javascript">
function do_action_page(form) {
var select_form = "";
var select_form = form.select_action.value;
if(select_form == ''){
	alert('empty select');
}
else {
	var select_form = form.frmUtils.action;
}
}
</script>
<select name="select_action" onchange="return do_action_page(this)">
<option value="add.php">add.php</option>
<option value="delete.php">delete.php</option>
<option value="update.php">update.php</option>
</select>

#this must be php file
$content = "";
$content .= "<form name = 'frmUtils' method = 'POST' action="">";
$content .= "<select name = Do>";
$content .= "<option>Add</option>";
$content .= "<option>Delete</option>";
$content .= "<option>Update</option>";
$content .= "</select>";
$content .= "</form>";
echo $content;

Link to comment
Share on other sites

Thanks for your help.  I'm trying it out but still troublesome

I want to put my actions in a switch

 

like

 

$Action = $_GET ['Function']

 

switch($Action)

{

 

case 'add':

      add function;

break;

 

case 'update':

    update function;

break;

 

case 'delete':

    delete function;

break;

}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.