CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2020-12-15
by Ashish

Original Post

Original - Posted on 2009-07-06
by Paolo Bergantino



            
Present in both answers; Present only in the new answer; Present only in the old answer;

This will help you for get the values.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
function myFunction(){ var e = document.getElementById("ddlViewBy1"); var e2 = document.getElementById("ddlViewBy"); var strUser1 = e2.value; var strUser = e.value; console.log(strUser); console.log(strUser1); }
<!-- language: lang-html -->
<select id="ddlViewBy1"> <option value="1">test1</option> <option value="2" selected="selected">test2</option> <option value="3">test3</option> </select>
<select id="ddlViewBy"> <option value="1" selected="selected">test1</option> <option value="2" >test2</option> <option value="3">test3</option> </select> <input type="submit" onclick="myFunction()"/>
<!-- end snippet -->

If you have a select element that looks like this:
<!-- language: lang-html -->
<select id="ddlViewBy"> <option value="1">test1</option> <option value="2" selected="selected">test2</option> <option value="3">test3</option> </select>
Running this code:
<!-- language: lang-js -->
var e = document.getElementById("ddlViewBy"); var strUser = e.value;
Would make `strUser` be `2`. If what you actually want is `test2`, then do this:
<!-- language: lang-js -->
var e = document.getElementById("ddlViewBy"); var strUser = e.options[e.selectedIndex].text;
Which would make `strUser` be `test2`

        
Present in both answers; Present only in the new answer; Present only in the old answer;