Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to set value using document.getElementById() 1

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
Hi all

Trying to reset the "slider" as defined here back to the default value of "1"

HTML:
<div id="slider-wrapper">
<label for="fader" title="Click here to reset" onclick="scaleinvoice('1')">Zoom</label>
<input type="range" min="0.5" max="1.5" value="1" step="0.1" oninput="scaleinvoice(value)" id="fader">
<output for="fader" id="percent">100%</output>
</div>

Code is
HTML:
document.getElementById("content").value = "1";
and is called in the function scaleinvoice().

Unfortunately the value is not reset - ideas, please?

TIA

FAQ184-2483​
Chris [pc2]
motrac.co.uk
 
Hi

You accidentally cut off the HTML containing the tag with [tt]id="content"[/tt] attribute. Please show that too so we see the full picture.


Feherke.
feherke.github.io
 
Feherke

Thanks for your reply and apologies for the omission.

html is:-

HTML:
<div id="content">
   <div id="row_1_col_1"></div>
   <div id="row_1_col_2"></div>
   <div id="row_1_col_3"></div>
   <div id="row_1_col_4"></div>
   <div id="row_1_col_5"></div>
   <div id="row_1_col_6"></div>
   <div class="clear_left"></div>	
</div>

css is:-

CSS:
#content {
   z-index: -1;
   position:relative;
   width:1050px;
   height:757px;
   margin:auto;
   background-image: url('../pngs/mhinvoice.png');
   background-repeat:no-repeat;
   background-size:auto;
   -ms-transform: scale(1,1); /* IE 9 */
   -webkit-transform: scale(1,1); /* Safari */
   transform: scale(1,1); /* Standard syntax */	
}

FAQ184-2483​
Chris [pc2]
motrac.co.uk
 
Hi

But that is a [tt]div[/tt]. [3eyes] Those have no [tt]value[/tt] attribute, so neither the [tt]HTMLDivElement[/tt] object returned by [tt]document.getElementById("content")[/tt] will handle such property.

Sure the tag with [tt]id="content"[/tt] should not be an [tt]input[/tt] tag instead ?

Or maybe your code should reference fader instead ?
Code:
document.getElementById("[highlight]fader[/highlight]").value = "1";

Feherke.
feherke.github.io
 
feherke

So obvious it's no true - using document.getElementById("content") a number of times in the function scaleinvoice() and somehow did not see the error.

HTML:
document.getElementById("fader").value = "1";

resolves the issue.

Many thanks for your fresh eyes.

FAQ184-2483​
Chris [pc2]
motrac.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top