如何从gridview的下拉列表中获取javascript中的选定值

时间:2017-03-17 05:52:41

标签: javascript

如何在javascript下面检索dropdownlist [ddrateplan]的值,下拉列表位于gridview [DataExtensionList]中。

isPmBoxOpenList

这是我尝试过的javascript示例,但它无法正常工作..

StringRequest stringRequest = new StringRequest(Request.Method.POST, AppConfig.URL_LOGIN, new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.d(TAG, response.toString());
                    progressDialog.dismiss();

                    JSONObject jsonObject = null;

                    try {
                        jsonObject = new JSONObject(response);

                        if(jsonObject.has("success")){
                            if(jsonObject.getBoolean("success") == true){
                                JSONObject userObject = new JSONObject(jsonObject.getString("user"));

                                Map<String, String> loginDetails = new HashMap<String, String>();
                                loginDetails.put(KEY_IS_LOGGED_IN, "true");
                                loginDetails.put(ACCESS_TOKEN, jsonObject.getString(ACCESS_TOKEN));
                                loginDetails.put(USERID, userObject.getString(USERID));
                                loginDetails.put(FIRSTNAME, userObject.getString(FIRSTNAME));
                                loginDetails.put(LASTNAME, userObject.getString(LASTNAME));
                                loginDetails.put(EMAIL, userObject.getString(EMAIL));

                                session = new SessionManager(_myActivity);
                                session.setLogin(loginDetails);

                                Intent intent = new Intent(LoginActivity.this, SearchActivity.class);
                                intent.putExtra("FROM_ACTIVITY", "LoginActivity");
                                startActivity(intent);
                                LoginActivity.this.finish();
                            }else{
                                btnLogin.setClickable(true);
                                btnLogin.setEnabled(true);
                                Toast.makeText(getApplicationContext(), "Username or Password does not matched!", Toast.LENGTH_LONG).show();
                            }
                        }

                    } catch (JSONException e) {
                        btnLogin.setClickable(true);
                        btnLogin.setEnabled(true);
                        e.printStackTrace();
                        Toast.makeText(getApplicationContext(), "Something went wrong, Please try agian", Toast.LENGTH_LONG).show();
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d(TAG, error.toString());
                    progressDialog.dismiss();

                    btnLogin.setClickable(true);
                    btnLogin.setEnabled(true);
                }
            }){
                @Override
                protected Map<String, String> getParams() {
                    // Posting parameters to login url
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("grant_type", "password");
                    params.put("username", email);
                    params.put("password", password);
                    return params;
                }

                @Override
                public Map<String, String> getHeaders() throws AuthFailureError {
                    Map<String,String> params = new HashMap<String, String>();
                    params.put("Content-Type", "application/x-www-form-urlencoded");
                    return params;
                }

                @Override
                public String getBodyContentType(){
                    return "application/x-www-form-urlencoded";
                }
            };

            stringRequest.setRetryPolicy(new DefaultRetryPolicy(5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

            // Adding request to request queue
            RequestQueue mRequestQueue = Volley.newRequestQueue(getApplicationContext());

            mRequestQueue.add(stringRequest);

1 个答案:

答案 0 :(得分:1)

我得到了我的答案,只需添加dropdown [ddrateplan]的属性为clientidmode =&#34; static&#34;并替换javascript的行

     var gv = document.getElementById("<%=DataExtensionList.ClientID %>");
     var dropvalue = gv.getElementsByTagName('ddrateplan');

用这个

     var dropvalue = $("#ddrateplan").val();