---
title: "Multiple ids with getElementById();"  
description: "Multiple ids with getElementById();"  
author: "Anonymous User"  
published: 2013-08-19  
updated: 2013-08-19  
canonical: https://www.mindstick.com/forum/1396/multiple-ids-with-getelementbyid  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# Multiple ids with getElementById();

Hi [Developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs)!\

I'm [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to get [javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) to write html on a page when a link is clicked.

[function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) updatetext(){

var file = document.getElementById("file").[value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages);

document.getElementById('updated').innerHTML = file;

}

<input id="file" value="text I want to write to the page" type="[hidden](https://www.mindstick.com/forum/2303/skip-validating-field-from-hidden-div)">

<span id="updated">&nbsp;</span>

This works for an ID labeled "file" but I have [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) ID's like, file1, file2, file3...

I'm wondering if my [onclick](https://www.mindstick.com/forum/12718/onclick-for-hyperlink)="updatetext()"; should have some argument like onclick="updatetext(1)"; but that doesn't seem to work. I'm not sure how to get the [right](https://www.mindstick.com/articles/12766/check-whether-you-are-doing-digital-transformation-right-or-not) input id from clicking on the link.

thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by shreesh chandra shukla

Hi!try this,it may may be resolve your problem\

```
function updatetext(id){    var file =document.getElementById("file" + id).value;   
document.getElementById('updated').innerHTML = file;}
```

That should do it, if you want to do what I interpreted


---

Original Source: https://www.mindstick.com/forum/1396/multiple-ids-with-getelementbyid

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
