Graeme McGilvray
asked on
Auto Submit on dropdown box
I had this question after viewing Auto Submit on dropdown box.
Hi all, I have sucessfully used this, however on the same page I have a 2nd auto submit (ClientCurr) I would like to use, however....when I try to submit it uses the (Championship) submit, instead of its own (ClientCurr)
Here is the 2x submits
Here is the If statement:
Any help is appreciated
Hi all, I have sucessfully used this, however on the same page I have a 2nd auto submit (ClientCurr) I would like to use, however....when I try to submit it uses the (Championship) submit, instead of its own (ClientCurr)
Here is the 2x submits
Response.Write("<select name=clientcurr class=inputbox onchange='javascript:this.form.submit();'>")
Response.Write("<option>"&ClientCurr&"</option>")
Response.Write("<option>---</option>")
Do Until SiteCurrency.EOF
Response.Write("<option>"&SiteCurrency("country_curr")&"</option>")
SiteCurrency.MoveNext
Loop
SiteCurrency.Close
Response.Write("</select>")
Response.Write("<select name=championship class=inputbox onchange='javascript:this.form.submit();'>")
Response.Write("<option>Select Championship</option>")
Response.Write("<option>---</option>")
Do Until Championship.EOF
Response.Write("<option>"&Championship("code_name")&"</option>")
Championship.MoveNext
Loop
Championship.Close
Response.Write("</select>")
Here is the If statement:
If Request.Form("championship")<>"" Then
ElseIf Request.Form("clientcurr")<>"" Then
End If
Any help is appreciated
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers for that! :)
I think its making more sense now...
Have just applied the code changes, not much success thou - it is not attempting to submit any of the select boxes
I think its making more sense now...
Have just applied the code changes, not much success thou - it is not attempting to submit any of the select boxes
dim mode : mode = Request.Form("mode")
If mode="championship" Then
oConn.Execute("INSERT INTO site_log(log_session,brand_ID,log_page,log_date,log_time) VALUES("&Session_ID&",'"&SubDomain("brand_ID")&"','Show "&Request.Form("championship")&"','"&Date()&"','"&Time()&"')")
Set Championship=oConn.Execute("SELECT * FROM codes WHERE code_name='"&Request.Form("championship")&"'")
Response.Redirect("?code="&Championship("code_short"))
ElseIf mode="clientcurr" Then
Set oXMLHTTPClient=CreateObject("MSXML2.ServerXMLHTTP")
ClientCurrAPI="http://apilayer.net/api/live?access_key=c1c108f1b397902542f2961ef3a98c30¤cies="&Request.Form("clientcurr")&"&source=USD&format=1"
oXMLHTTPClient.Open "GET",ClientCurrAPI, False
oXMLHTTPClient.Send
If oXMLHTTPClient.Status=200 Then
GetTextFromUrlClient=oXMLHTTPClient.responseText
ArrClient1=Split(GetTextFromUrlClient,"USD"&SessionCurr("country_curr"))
ArrClient2=Split(ArrClient1(1),":")
ArrClient3=Split(ArrClient2(1)," ")
ClientConvert=CDbl(ArrClient3(0))
End If
oConn.Execute("UPDATE site_sessions SET session_curr='"&SessionCurr("country_curr")&"',session_rate="&ClientConvert&",session_date='"&Date()&"',session_time='"&Time()&"' WHERE session_ID="&Session.SessionID)
Response.Redirect("?")
End If
Response.Write("<input type='hidden' name='mode' id='mode' value='' />")
Set Championship=oConn.Execute("SELECT * FROM codes WHERE code_live=TRUE ORDER BY code_name")
Response.Write("<td width=1000 height=40 align=left valign=absmiddle> ")
Set ClientCountry=oConnAE.Execute("SELECT * FROM IATA_country WHERE IATA_2letter='"&ClientRegion&"'")
Response.Write("<img height=30 width=30 valign=middle src=http://members.amnet.net.au/~webber4/flag-"&ClientRegion&".png> <b>"&ClientCountry("IATA_country")&"</b>")
Set SiteCurrency=oConnAE.Execute("SELECT * FROM IATA_country WHERE curr_default=TRUE ORDER BY country_curr")
Response.Write(" <select name=clientcurr class=inputbox onchange='javascript: document.getElementById('mode').value = 'client'; this.form.submit();'>")
Response.Write("<option>"&ClientCurr&"</option>")
Response.Write("<option>---</option>")
Do Until SiteCurrency.EOF
Response.Write("<option>"&SiteCurrency("country_curr")&"</option>")
SiteCurrency.MoveNext
Loop
SiteCurrency.Close
Response.Write("</select></td>")
Response.Write("<td width=330 height=40 nowrap align=center><select name=championship class=inputbox onchange='javascript: document.getElementById('mode').value = 'championship'; this.form.submit();'>")
Response.Write("<option>Select Championship</option>")
Response.Write("<option>---</option>")
Do Until Championship.EOF
Response.Write("<option>"&Championship("code_name")&"</option>")
Championship.MoveNext
Loop
Championship.Close
Response.Write("</select></td>")
All the code is snipets from the page
do you have a link to the page?
ASKER
I have PMd you the link and login details
Why not just put each <select> in its own form.
That way when you do a this.form.submit() it submits the contents of the form that contains the <select> that triggered the submit.
You don't need them to be in the same form as each is doing an autosubmit and are therefore mutually exclusive.
HTML
That way when you do a this.form.submit() it submits the contents of the form that contains the <select> that triggered the submit.
You don't need them to be in the same form as each is doing an autosubmit and are therefore mutually exclusive.
HTML
<form action="reflect.php" method="post">
<select name="clientcurr" class="inputbox" onchange="javascript:this.form.submit();">
<option>Option 1</option>
<option>---</option>
<option>GBP</option>
<option>USD</option>
<option>ZAR</option>
</select>
</form>
<form action="reflect.php" method="post">
<select name="championship " class="inputbox" onchange="javascript:this.form.submit();">
<option>Option 1</option>
<option>---</option>
<option>ABC</option>
<option>DEF</option>
<option>GHI</option>
</select>
</form>
Working sample here
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the onchange for both is different (quotes within), is this to test which works?
tried clientcurr
clientcurr, is submitting but i dont think to where it should, as it should be stopping at a Response.Write("updated")
Response.Write("<td width=330 height=40 nowrap align=center><select name=championship class=inputbox onchange=""javascript: document.getElementById('mode').value = 'championship'; this.form.submit();"">")
- this works for championshiptried clientcurr
Response.Write(" <select name=clientcurr class=inputbox onchange='javascript: document.getElementById(""mode"").value = ""client""; this.form.submit();'>")
changed clientcurr to below to match championship quotes aboveResponse.Write(" <select name=clientcurr class=inputbox onchange=""javascript: document.getElementById('mode').value = 'client'; this.form.submit();"">")
clientcurr, is submitting but i dont think to where it should, as it should be stopping at a Response.Write("updated")
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Separate forms?
not a big fan of multiple forms, as I don't find the scale well. if you need to add additional data fields to the page that are outside of the form elements, then it takes a lot more work to get it to work than simply adding a flag to the data that's posted and checking against that flag
just my .02 cents worth :)
just my .02 cents worth :)
Except in this case that is exactly what he is doing - submitting mutually exclusive data.
Makes sense to use separate forms as it ring fences the contained control from any other control - no possibility of a mix up.
Scaling is going to be problematic any way you slice this thing as you are breaking the mold of how forms work (fields / submit button).
Personally I think it is the simplest solution.
Makes sense to use separate forms as it ring fences the contained control from any other control - no possibility of a mix up.
Scaling is going to be problematic any way you slice this thing as you are breaking the mold of how forms work (fields / submit button).
Personally I think it is the simplest solution.
ASKER
Cheers BigMonty, working a treat! :)
ASKER
So I am guessing that this type of submit will just take whichever is first in line? for Request.Form's?
for dim mode : mode - where do i position this?