0

I am trying to develop a site that on entering a value into an input changes page content. I have gotten this to work with my photos. I am pulling text from a .txt file using HTML "Object".

I want to change the file path for the text file using the input as the parent folder. I tried using inner.html, and setting the id data = but neither worked.

I'm open to any suggestions.

function myFunction() {
  var x = document.getElementById("stud").value ;
  var a = x + "/img1.jpg" ;
  var b = x + "/img2.jpg" ;
  var text_hold = x + "/text/text.txt" ;
  img1.src= a ;
  img2.src= b ;
  document.getElementById("content").innerHTML = "data='jeff/stock/text/text.txt'" ;
}
3
  • forgot the element <div><object id="content" data="stock/text/text.txt"></object></div> Commented Mar 31, 2016 at 1:52
  • Don't put corrections into the comments, edit the question. Commented Mar 31, 2016 at 1:57
  • Possible duplicate of Ajax tutorial for post and get Commented Mar 31, 2016 at 2:32

1 Answer 1

1

data is an attribute, it's not the HTML contents of the object. Use setAttribute to set it.

document.getElementById('content').setAttribute('data', 'jeff/stock/text/text.txt');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.