Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how i open this link in new tab?

function myFunction() {

  var x = document.getElementById("frm1");

  var text = "";

  var i;

  for (i = 0; i < x.length ;i++) {

    text += x.elements[i].value;

  }
  
window.open(text, "_blank");
  document.getElementById("demo").innerHTML = text;


}
.center {

  margin: auto;

  width: 60%;

  border: 3px solid #003fff;

  padding: 10px;

  text-align: center;
}
<div class="center">

<h3>go to city</h3>



<form id="frm1">

  link: <input type="text" name="fname" value=https://it.wikipedia.org/wiki/><br><br>

  City: <select name="lname">

  <option value="roma">Rome</option>

  <option value="miami">Miami</option>

</select><br><br>



</form>



<p>choose your city .</p>



<button onclick="myFunction()">open</button>



<p id="demo"></p>

</div>

<html>

<head>

<style>

.center {

  margin: auto;

  width: 60%;

  border: 3px solid #003fff;

  padding: 10px;

  text-align: center;

}

</style>

</head>

<body>

<div class="center">

<h3>go to city</h3>

 

<form id="frm1">

  First name: <input type="text" name="fname" value=https://it.wikipedia.org/><br><br>

  City: <select name="lname">

  <option value="Milano">Milano</option>

  <option value="Firenze">Firenze</option>

</select><br><br>

 

</form>

 

<p>choose your city .</p>

 

<button onclick="myFunction()">open</button>

 

<a href id="demo"></a>

</div>
`
<script>

function myFunction() {

  var x = document.getElementById("frm1");

  var text = "";

  var i;

  for (i = 0; i < x.length ;i++) {

    text += x.elements[i].value;

  }

  document.getElementById("demo").innerHTML = text;

}

</script>
`
 

</body>

</html>

>Solution :

Use this line in myfunction()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

window.open(text, "_blank");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading