Link to home
Start Free TrialLog in
Avatar of superabbe
superabbe

asked on

Form / Post Action suing combo box

Hello everybody...

My friend Babban asked this question but didn't got any answeres. Im curious myself.

Can I by using a a form, combobox and a send button post different actions letting the combo box control the action?

Let say my combobox have 3 values.

"Projects" (action=page1.asp)
"Programs" (action=page2.asp)
"Production" (action=page3.asp)

Is this possible in some way. This could be useful I think. Some trick or a solution that reminds of this?

Rgrds

ASKER CERTIFIED SOLUTION
Avatar of Göran Andersson
Göran Andersson
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of superabbe
superabbe

ASKER

Hi.
Almost what I want.
Wait..I post my code here. I use SQL tabels.
I have added one field to my table named 'DestinationPage'.
How can I implement that to my code/combobox, that field should hold the post action information (example: page1.asp). It shall be hidden.

How can I then Post the value as I do here and also post the action to the destination in field 'DestinationPage'?

<form name="Selecthelpdesk">
  <table border="0">
    <tr>
      <td>HELPDESK v 0.01</td>
    </tr>
    <tr>
      <td class='headline'>Select helpdesk<br>
        <select name="Group" size="1">
          <%
set remoteconn=server.CreateObject("ADODB.connection")
remoteconn.Open "Provider=SQLOLEDB.1;Driver={SQL  Server};SERVER=aa;DATABASE=Helpdesk;UID=sa;PWD=;"

SQLstmt = "SELECT * from tblAssignToGroup"
Set assign = remoteconn.Execute(SQLstmt)
selstring="selected"
While Not assign.EOF
Response.write "<option " & selstring & " value=""" & assign("AssignToGroupName") & """>" & assign("AssignToGroupName")& "</option>"
selstring=""
assign.movenext
wend
%>
        </select>
      </td>
    </tr>
    <tr>
      <td><b>
        <input type="button" value="Send" onClick="this.form.submit()" name="button">
        </b></td>
    </tr>
  </table>
</form>
Try these changes:

Response.write "<option " & selstring & " value=""" & assign("DestinationPage") & """>" & assign("AssignToGroupName")&
"</option>"

<input type="button" value="Send" onClick="this.form.action=this.form.Group.value;this.form.submit();" name="button">
But AssignToGroupName holds values like

AABB
BBAA
CCDD

That must be trigged on the 'destination page'...

?
Oh, ok. As long as the url:s don't contain a semicolon (;), these additional changes should do it:

<input type="hidden" name="Group">
<select name="GroupList" size="1">

<input type="button" value="Send" onClick="this.form.action=this.form.GroupList.value;this.form.Group.value=this.form.GroupList(this.form.GroupList.selectedIndex).text;this.form.submit();" name="button">
Eh, forget that about the semicolon. That was from a different solution I had in mind.
<Script>

Function SomeFunction()
{
document.frm.action=document.frm.option.value;
document.frm.submit()
}
</Script>

<form name="frm" action=SomePage.asp>
<select name="option" OnChange=SomeFunction()>
<option value="page1.asp"> Option 1
<option value="page2.asp">Option 2
<option value="page3.asp">Option 3
</select>
</form>


Just check it for grammer ... this is the solutuion you needd.... but some small mistake of Comma and all may be there ... Alryte

Get Going

Mihir

Mihirl, yes, except you don't have a submit button. And if the user does not change the option, it does not go to the page of the default option. And superabbe needs the text of the options on the next page, that code doesn't do that.

Read the previous postings.
I think GreenGhost have a correct answere.
I think GreenGhost have a correct answere.
mihirl, it is rude to lock up a question, especially when you are just repeating someone else's answer.
Someone else was first.
Hey ! Buddy ... ity was by mistake .. i had no intentions of selecting answetr ....anyways ....

Thanx

Mihir