Setting the value of a CSS property to .value

Currently, I am engrossed in a small project.

Here's the gist: I aim to read text field values and assign them to corresponding CSS rules.

For example,

    document.getElementById("BD").value;

The value being read should be assigned to border-radius.

   .style.border-radius:<VALUE>px;

But how do I establish that connection?

If I have three divs with individual names, how can I ensure they only apply to the selected div?

EDIT: Complete HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Opdracht 1</title>

<link rel="stylesheet" type="text/css" href="css.css" />
<script language="javascript">
function BorderDikte(){
    document.getElementById("BD").value;
    document.getElementById("BS").value;
    document.getElementById("BK").value;
}

</script>
</head>

<body>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<br /><br /><br /><br /><br /><br /><br />
<table width="750" border="1" cellspacing="3" style="float:left;">
  <tr>
    <td width="318">Border dikte (thin, medium, thick)</td>
    <td width="419"><textarea id="BD"></textarea></td>
  </tr>
  <tr>
    <td>Border soort (dashed, dotted, solid or double)</td>
    <td><textarea id="BS"></textarea></td>
  </tr>
  <tr>
    <td>Border kleur (bijvoorbeeld #000 of #FFF</td>
    <td><textarea id="BK"></textarea></td>
  </tr>
  <tr>
    <td>Welke Div? ( 1, 2 of 3)</td>
    <td><textarea id="DN"></textarea></td>
  </tr>
  <tr>
    <td align="center"></td>
    <td>&nbsp;<button>Go</button></td>
  </tr>
  <tr>
    <td align="center"></td>
    <td>&nbsp;<button>Reset</button></td>
  </tr>
  <tr>
    <td align="center"></td>
    <td>&nbsp;<button>Onzichtbaar</button></td>
  </tr>
</table>

</body>
</html>

EDIT 2:

I need to rephrase my explanation...

For instance

[] [] []

Border = thick
Border color = #0F0
Border style = Solid
Which div = 2
Press go

The values are now being read and processed into my CSS so that only the second div (div 2) is updated.

[] **[]** []

     ^
     Red and solid

Border       = [textfield empty]
Border color = [textfield empty]
Border style = [textfield empty]
Which div?   = [textfield empty]

Answer №1

as seen here:

XHTML

<section id = "one"></section><section id = "two"></section><section id = "three"></section>

JavaScript

var borderSize = parseInt(document.getElementById("BS").value, 10);
document.getElementById("one").style.borderWidth = borderSize + "px";

i might have misinterpreted your inquiry, so please provide more details or include a snippet of your code.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for accessing and storing an uploaded image in a Next.js application?

How can I retrieve an uploaded image in a next.js API route and save it to the public folder? My frontend is all set up, and I'm currently uploading images to an endpoint using plain JavaScript. Below is the onSubmit function for uploading images. Ple ...

Utilize a dual-color gradient effect on separate words within the <li> element

I am attempting to display the fizz buzz function in an unordered list, with each word being a different color ('fizz'-- green, 'buzz'--blue) as shown here: https://i.sstatic.net/Yvdal.jpg I have successfully displayed "fizz" and "buz ...

Ordering items in Angular Filter OrderBy is based on a specific string sequence, rather than following

As I iterate through a list of objects in an ng-repeat, I am facing the challenge of sorting them based on their 'approved' attribute. The possible values for 'approved' are 'APPROVED', 'DENIED', or 'PENDING&apo ...

Exploring the possibilities of implementing the .map() function on a JSONArray within a ReactJS project using ES

When I receive a JSONArray from the server, my goal is to use .map() on it in order to extract key-value pairs of each object within the array. However, when I try to implement this code, I encounter an error stating "files.map is not a function". Can some ...

Is there a way to convert HTML websites into JSON format using Cheerio and Puppeter?

Just dipping my toes into the world of JS here. I have a burning question - How exactly can we scrape an HTML website and store it as a JSON file? https://i.sstatic.net/BJtwO.png The website in question is an examination test portal. It's loaded wit ...

How about "Can I position two divs on the right side of the page

After browsing through some StackOverflow threads and other sources, I'm still struggling to figure out how to float two divs to the right while aligning them vertically (with the "sign in" div on top). Based on my findings, here are the key points: ...

Is it possible to maintain a fixed footer while utilizing async/ajax functions?

Looking for a reliable solution to have a fixed footer that adjusts based on the page content? I've tested multiple samples, but they all fall short when it comes to incorporating AJAX elements. Is there a fixed footer out there that truly works seaml ...

The RouterView component seems to be malfunctioning within the Vue project

I recently started working on a vue-project where I created a Home page with a sideBar component and a routerView component. Here's a preview: https://i.sstatic.net/f51tdsZ6.png When clicking on any sidebar item, the router navigates to the corresp ...

Guide to quickly redirecting all 404 links to the homepage on a simple HTML website

Is there a way to automatically redirect clients to the homepage if they click on a broken link in a basic HTML website, instead of displaying a custom 404 page? UPDATE: My website consists of only 5 plain HTML pages hosted on GoDaddy. There is no server- ...

Avoid repetitive clicking of the button to activate the function

Is there a way to prevent spamming of a button when calling a function? I want the user to only be able to call the function once every second when clicking the button. I have tried using setTimeout but it doesn't seem to work, as it still allows for ...

How can `${}` be utilized within Angular applications?

Within TypeScript component files in Angular projects, I often come across this particular syntax enclosed in backticks: <div ${selector} [inDemo]="false" [config]="demoConfig">Demo Content</div> I'm curious about the purpose of the ${} ...

What is the reason that textContent assignment does not function properly when used with HTML tags?

I have been attempting to insert additional text into an existing element using the textContent property. However, when I use the += operator for addition assignment, it seems to strip away the formatting of pre-existing tags like b. I expected that the ne ...

Removing the blue border around a button upon being clicked

Whenever I press my button, an unexpected event occurs. Is there a solution to avoid this issue? Thank you for your help! :) ...

Align an image vertically beside a paragraph

I've been attempting to align an image, which is typically shorter in height than the paragraph next to it, in the middle vertically but just can't seem to figure it out. <div class="element"> <img src="http://dummyimage.com/75" /& ...

Display tooltips on top of z-index stacking contexts

I am struggling to display a tooltip within a table field, on top of other fields and tables. The issue lies in the fact that the other tables and elements are housed within different DIVs that have set the CSS z-index property to 0. Even if I assign a hi ...

Issue with updating required Node.js/Express modules using Chokidar?

After browsing through numerous questions and answers regarding chokidar, I am still struggling with an issue. It would be greatly appreciated if someone could help debug my particular code snippet. The Express node app I am working on is running at local ...

Substituting placeholders within a docx template remains incomplete

Utilizing this specific library, I am implementing a feature to substitute placeholders within a docx template and generate multiple documents. The technologies involved are neutralino and vue for the front-end, where I have devised a method that transmits ...

Python form submission error code 405 encountered

I recently developed a simple WSGI Server using Google app engine. Here's an example of the code: import webapp2 class MainHandler(webapp2.RequestHandler): def get(self): self.response.write(''' ...

Is ngSwitch in Angular causing the label element to disappear?

I am using AngularJS to generate form elements dynamically based on an array containing form details such as input type and value. For example, here is the code snippet I have for creating a text input field: <div ng-repeat="input in input_array"> ...

Signing in using Passport.js with mongoDB authentication

Apologies if this question appears redundant, but I am struggling to resolve an issue with a "MISSING CREDENTIALS" error when trying to implement user login using email and password. Despite going through numerous responses, none have provided a solution. ...