OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Scan QR Code value into an input field after successful scan

  • Thread starter Thread starter 13garth
  • Start date Start date
1

13garth

Guest
This is the scanner I am using...

https://github.com/takanori-matsushita/webcodecamjs

It's working 100%. But I need to add some custom extra's.

When the QR Code is scanned it outputs my result into this paragraph tag.

Code:
<p id="scanned-QR"> The scanned code text value is printed out here </p>

However I need it to be an input field so I can use it's value in a url.

How can I set an input field equal to the value submitted to the Paragraph tag?

I have tried these methods and they failed :

Method 1

Code:
<input id="scanned-QR"> The scanned code text value is printed out here </input>

Method 2

Code:
<p id="scanned-QR" onchange="update"></p>
 <input id="code_id_value" type="text" name="" value="">
<br>

<script>
 function update(){
  var code_id_value = document.getElementById("scanned-QR").innertext;
  document.getElementById("code_id_value").value = code_id_value;
 }
</script>

<p>This is the scanner I am using...</p>
<p><a href="https://github.com/takanori-matsushita/webcodecamjs" rel="nofollow noreferrer">https://github.com/takanori-matsushita/webcodecamjs</a></p>
<p>It's working 100%. But I need to add some custom extra's.</p>
<p>When the QR Code is scanned it outputs my result into this paragraph tag.</p>
<pre><code><p id="scanned-QR"> The scanned code text value is printed out here </p>
</code></pre>
<p>However I need it to be an input field so I can use it's value in a url.</p>
<p>How can I set an input field equal to the value submitted to the Paragraph tag?</p>
<p>I have tried these methods and they failed :</p>
<p>Method 1</p>
<pre><code><input id="scanned-QR"> The scanned code text value is printed out here </input>
</code></pre>
<p>Method 2</p>
<pre><code><p id="scanned-QR" onchange="update"></p>
<input id="code_id_value" type="text" name="" value="">
<br>

<script>
function update(){
var code_id_value = document.getElementById("scanned-QR").innertext;
document.getElementById("code_id_value").value = code_id_value;
}
</script>
</code></pre>
 
Top