INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Unable to set value using document.getElementById()

Unable to set value using document.getElementById()

(OP)
Hi all

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

CODE --> 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

CODE --> html

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

Unfortunately the value is not reset - ideas, please?

TIA

Chris pc2
motrac.co.uk

RE: Unable to set value using document.getElementById()

Hi

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

Feherke.
feherke.github.io

RE: Unable to set value using document.getElementById()

(OP)
Feherke

Thanks for your reply and apologies for the omission.

html is:-

CODE --> 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:-

CODE --> 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 */	
} 

Chris pc2
motrac.co.uk

RE: Unable to set value using document.getElementById()

Hi

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

Sure the tag with id="content" should not be an input tag instead ?

Or maybe your code should reference fader instead ?

CODE --> JavaScript ( fragment )

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

Feherke.
feherke.github.io

RE: Unable to set value using document.getElementById()

(OP)
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.

CODE --> html

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

resolves the issue.

Many thanks for your fresh eyes.

Chris pc2
motrac.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close