JavaScript:两个下拉重定向提交

时间:2018-11-12 02:41:19

标签: javascript redirect dropdown

我的第二个下拉列表为:

MainActivity:
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import com.google.firebase.auth.FirebaseAuth
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {

    lateinit var mAuth: FirebaseAuth

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        mAuth = FirebaseAuth.getInstance()
        signOut.setOnClickListener {
            view: View? -> mAuth.signOut()
            startActivity(Intent(this, PhoneAuthentication::class.java))
            Toast.makeText(this, "Logged out Successfully :)", Toast.LENGTH_LONG).show()
        }
    }


    override fun onStart() {
        super.onStart()
        if (mAuth.currentUser == null) {
            startActivity(Intent(this, PhoneAuthentication::class.java))
        }else {
            Toast.makeText(this, "Already Signed in :)", Toast.LENGTH_LONG).show()
        }
    }

}

PhoneAuthentication.kt
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import com.google.android.gms.tasks.Task
import com.google.firebase.FirebaseException
import com.google.firebase.auth.AuthResult
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.PhoneAuthCredential
import com.google.firebase.auth.PhoneAuthProvider
import kotlinx.android.synthetic.main.activity_phone_authentication.*
import java.util.concurrent.TimeUnit


class PhoneAuthentication : AppCompatActivity() {

    lateinit var mCallbacks: PhoneAuthProvider.OnVerificationStateChangedCallbacks
    lateinit var mAuth: FirebaseAuth
    var verificationId = ""


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_phone_authentication)
        mAuth = FirebaseAuth.getInstance()
        veriBtn.setOnClickListener {
            view: View? -> progress.visibility = View.VISIBLE
            verify ()
        }
        authBtn.setOnClickListener {
            view: View? -> progress.visibility = View.VISIBLE
            authenticate()
        }
    }


    private fun verificationCallbacks () {
        mCallbacks = object: PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
            override fun onVerificationCompleted(credential: PhoneAuthCredential) {
                progress.visibility = View.INVISIBLE
                toast("LoggedIn Success :)  "+ credential)
                signIn(credential)
            }

            override fun onVerificationFailed(p0: FirebaseException?) {
                TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
            }

            override fun onCodeSent(verfication: String?, p1: PhoneAuthProvider.ForceResendingToken?) {
//                super.onCodeSent(verfication, p1)
                verificationId = verfication.toString()
                progress.visibility = View.INVISIBLE
            }

        }
    }

    private fun verify () {

        verificationCallbacks()

        if(phnNoTxt.text.length>=13) {
            val phnNo = phnNoTxt.text.toString()
            PhoneAuthProvider.getInstance().verifyPhoneNumber(
                    phnNo,
                    60,
                    TimeUnit.SECONDS,
                    this,
                    mCallbacks
            )
        }
        else{
            toast("please enter a valid contact number with country code!!")
            progress.visibility = View.INVISIBLE
        }


    }

    private fun signIn (credential: PhoneAuthCredential) {
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener {
                    task: Task<AuthResult> ->
                    if (task.isSuccessful) {
                        toast("LoggedIn Success !!)")
                        startActivity(Intent(this, MainActivity::class.java))
                    }
                }
    }

    private fun authenticate () {

        val verifiNo = verifiTxt.text.toString()

        val credential: PhoneAuthCredential = PhoneAuthProvider.getCredential(verificationId, verifiNo)

        signIn(credential)

    }

    private fun toast (msg: String) {
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show()
    }


}
ExampleInstrumentedTest.kt

import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @Test
    fun useAppContext() {
        // Context of the app under test.
        val appContext = InstrumentationRegistry.getTargetContext()
        assertEquals("com.winision.phoneauth", appContext.packageName)
    }
}

如何使用Javascript提交重定向选择下拉列表

如果<form id="redirect"> <select id="location"> <option value="bus">Bus</option> <option value="station">Station</option> <option value="office">Office</option> </select> <select id="goto"> <option value="home">Home</option> <option value="city">Cty</option> </select> <input type="submit" value="submit"></input> </form> =>单击提交重定向= >> google.com

如果#location = Bus && #goto = Home =>单击提交重定向= >> facebook.com

与其他#location匹配

如果#location = Bus && #goto = Cty =>单击提交重定向= >> url1.com

如果#location = Station && #goto = Home =>单击提交重定向= >> url2.com

非常感谢您!

1 个答案:

答案 0 :(得分:0)

这是您的操作方式:

foreach($categories as $cat) {
  if ($i == $len - 1) {
    echo '<li><h2><a href="'.get_category_link($cat->cat_ID).'">'.$cat->name.'</a></h2></li>';
  } else {
    echo '<li><h2><a href="'.get_category_link($cat->cat_ID).'">'.$cat->name.', </a></h2></li>';
  }
  $i++;
}

根据需要更改这些URL。