How do I make a cookie out of the user input from a form?

How do I make a cookie out of the user input from a form like this:

<form>
 <label for="name">Name:</label>
 <input type="text" id="name" name="name">
 <input type="submit" value="Submit">
</form>

or like this:

<form>
  <input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
  <label for="vehicle1"> I have a bike</label><br>
  <input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
  <label for="vehicle2"> I have a car</label><br>
  <input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
  <label for="vehicle3"> I have a boat</label>
</form>

Is there a way to disable jump links within a page or the div itself?

So, I’ve been trying to create a slider using only CSS and have been trying to avoid JS. Here’s what I’ve got so far:

:root{
  --width: 300px;
}
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: sans-serif;
}

.slider-content-box {
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.slide-outer{
  width: var(--width);
  background: #4e6cf2;
  border-radius: 15px;
  box-shadow: 0px 0px 16px 5px rgba(0,0,0,0.3);
}
.slider {
  text-align: center;
  position: relative;
}

.slides {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;

}
.img-section {
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  border: none;
  outline: none;
}

.img-section img {
  height: 250px;
  width: 100%;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.slides>div {
  color: white;
  flex-shrink: 0;
  width: var(--width);
  height: auto;
  padding: 20px 10px 50px 10px;
  position: relative;
  display: flex;
  text-align: left;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  font-weight: 400;
}
.slides>div:first-child{
  font-size: 20px;
  font-weight: 600;
}

.arrows {
  position: absolute;
  z-index: 1;
  display: inline-flex;
  column-gap: 10px;
  bottom: 18px;
  right: 25px;
}

.slider .arrows a {
  width: 1rem;
  height: 1rem;
  text-decoration: none;
  align-items: center;
  justify-content: center;
  position: relative;
}

.slider .arrows a img {
  height: 20px;
  width: 30px;
}

.non-active-arrow-right,
.non-active-arrow-left {
  display: none;
}

.slider-scroll-box{
  padding: 10px 0px;
}
.slides::-webkit-scrollbar {
  width: 10px;
  height: 2px;
  border-radius: 10px;
  margin: 0px 10px;
}

.slides::-webkit-scrollbar-thumb {
  background: #9c9c9c;
  border-radius: 10px;
  padding: 0 !important;
}

.slides::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
  margin: 0px 20px;
}

.blur-image{
  filter: brightness(0.5);
}
<div class="slider-content-box">
    <div class="slide-outer">
      <div class="img-section">
        <img src="https://fs.hubspotusercontent00.net/hubfs/20523656/Group%2024941.png" width="100%" height="200px">
      </div>
  
      <div class="slider-scroll-box">
        <div class="slider">
          <div class="arrows">
            <a href="#slide-1" id="image-1">
                <img src="https://fs.hubspotusercontent00.net/hubfs/20523656/left-arrow-active.svg" class="active-arrow-left">
            </a>
  
            <a href="#slide-2" id="image-2">
              <img src="https://fs.hubspotusercontent00.net/hubfs/20523656/right-arrow-active.svg" class="active-arrow-right">
            </a>
  
          </div>
          <div class="slides">
  
            <div id="slide-1">
              Hello, I'm <br> Joe. The dev <br> of
            </div>
            <div id="slide-2">
              lorem ispoumm lorem ispoumm lorem ispoumm lorem ispoummlorem ispoummlorem ispoumm lorem ispoumm
            </div>
  
          </div>
  
        </div>
      </div>
  
    </div>
  </div>

As you can see, I’m using hash links for the arrow buttons so that it moves from div to div. However, this doesn’t seem to be good practice because when it’s applied to a page, clicking the arrows prompts the viewport to jump where the arrows begin.

Is there a way to maybe disable the jumps within this div or the entire page? Would anyone have a different idea to get it to function the same but without the hash links?

Why does header shrink after getting vue js build?

It was a very silly thing. In localhost, my header component looks quite normal, but after rendering everything on the page stays in the same design, the header gets smaller.

I’m working on netflix clone project, why is my header design getting smaller while everything is building properly on the page?

I did not interfere with the header in any way as javascript. Why did such an event happen to me when I was only standing as a component?

How can I allow users on my site to list their NFTs for sale?

I have an existing e-commerce website and we are implementing Web3 capabilities to the site. Our users are given exclusive NFTs built on Solana and we want to allow them to list them for sale in our own Digital Asset marketplace. When a user goes into their profile they’re able to see all the NFTs they have acquired. When they want to list one of them for sale, they click on the item and click a “Add To Marketplace” button. If their wallet isn’t already connected it will ask them to connect their wallet. Once the wallet is connected… I don’t know what to do.
How do I create this transaction that allows the owner of the NFT to list it in our marketplace?

Sort DataTable – show selected rows first

I am using the table-plugin for jQuery DataTables to display a HTML-Table. In addition I am using the Select-Plugin which allows to (multi)select table rows. As a user select a row, the class “selected” is added to the <tr> element:

<tr id="tr_1" class="odd selected">

How can I sort the rows, that the selected rows are shown first? This would improve clarity, especially with many rows or pages provided by DataTable.

import web3 into react js getting BREAKING CHANGE: webpack < 5 used to incl

I am having problems with importing web3 into reactjs. To replicate my problem, initiallize a new react app as so

npx create-react-app my-app
cd my-app

then open terminal in this location. Write:

npm install web3
npm install

in the App,js file add the following line

import Web3 from "web3"; 

I got the error after I do npm start then I got the unsolved error which is

Module not found: Error: Can't resolve 'stream'

Module not found: Error: Can't resolve 'crypto'

I tried finding a solution online, in particular I tried each of

  1. How to Polyfill node core modules in webpack 5
  2. https://www.youtube.com/watch?v=u1PPNIBvQjk
  3. Importing web3 causing a problem in react js
  4. https://github.com/facebook/create-react-app/issues/11756#issuecomment-1001162736
  5. https://namespaceit.com/blog/how-fix-breaking-change-webpack-5-used-to-include-polyfills-for-nodejs-core-modules-by-default-error
  6. How to create React App including Web3 using create-react-app? I am getting Module not found Error. BREAKING CHANGE: webpack < 5 used

None seem to work with me. Is there any advice on how to solve this problem?
Thank you!

Is it possible to change the message within a repeating IOS notification in react native?

I’m currently working in react native for the first time, trying to create an iPhone app. it’s been going well so far, but I’ve come across a slight limitation that I’m not sure I can workaround.

I want to be able to randomly send the user a notification a couple of times throughout the day, I’ve learned that I could use “repeatType” within my “localNotificationSchedule” function to set up a recurring notification message, but the problem with this is the notification repeats the same message over and over, and I want these messages to be random. is there a way about doing this?

I’m using local push notifications, and these two packages:

https://github.com/zo0r/react-native-push-notification

https://github.com/react-native-push-notification/ios

How do you add an annotation to a website without altering the layout?

I’m working on a hobby project similar to markup.io where you can load in any website and annotate it. I can’t figure out how to add an annotation that behaves like it does in markup.io:

  • Doesn’t interrupt the styling or layout of the website you are annotating
  • The annotation keeps the correct position when scrolling and resizing the window

From what I can see they place an absolute positioned div inside the element that you clicked on. From my understanding by reading the docs that div would position itself based on the closest positioned ancestor. How would you calculate the correct top and left values to position the annotation to where the user clicked? Is there a better way to do this?

I’m using React if that matters.

Things that I have tried:

  1. Append the following bit of html to the element that was clicked:
<div style="width:0px; height:0px; position:relative;">
<div style="width:50px;height:50px;position:absolute; ">this is the annotation </div> 
</div>

Problem: This would mess with the page layout because of the relative positioned div that is not ignored by the document flow.

  1. Create fixed overlay over the entire page. Get the css selector of the clicked element. Draw annotation on the fixed overlay at the x,y position of the element.

Problem: Whenever the user would scroll or resize the window the annotation would need to be redrawn at the new position of the element. I used getBoundintClientRect to get the new position and this would cause a reflow and caused the whole website to have severe perfomance issues when dealing with 100+ annotations.

Hopefully someone can point me in the right direction!

try catch or async awaiit in useeffect for jest

I am running my first unit tests in JEST. I installed Jest Fetch Mock but I still receive an error, “The promise rejected with reason FetchError“.

I did some reading, and I guess that I need to add an async await or a try catch. Can someone help me with this?

This is the fetch I am making in useEffect.

const [data, setData] = useState(null);
  const [isLoading, setLoading] = useState(false);

  useEffect(() => {
    setLoading(true)
    
    fetch("https://api.github.com/search/repositories?q=created:%3E2017-01-10&sort=stars&order=desc")
    .then((res) => res.json())
      .then((data) => {
        setData(data)
        setLoading(false)
      })
  }, [500]);

Why value of c cos and javascript Math.cos is different?

I was just porting a c code to JavaScript and got stumbled on a weird issue, the value from c cos function is different from the value of Math.cos value which results in wrong output.

First
c cos:

cos(-1.570796) is 0.000000

while

First
JavaScript cos:

Math.cos(-1.570796) is 3.2679489653813835e-7

Second
c cos:

cos(-1.570796) is -1.000000

while

Second
JavaScript cos:

Math.cos(-1.570796) is -0.99999999999994

I can see that JavaScript Second one is close enough to -1.000000 but the first one is way off.

Can anyone please let me know how can i fix this?

How do I add CSS or JS to JSON that I’m retrieving from an API in Rails?

After several days of reading and learning, I’ve finally figured out how to call an API on a Rails app and display it on a page.

Obviously, the API is returning the request in a JSON format, which is what’s being displayed on the webpage. This is exactly what’s being displayed..

{"data"=>{"id"=>501, "active"=>true, "type"=>"domestic", "legacy_id"=>66, "country_id"=>1161, "logo_path"=>"https://cdn.sportmonks.com/images/soccer/leagues/501.png", "name"=>"Premiership", "is_cup"=>false, "is_friendly"=>false, "current_season_id"=>18369, "current_round_id"=>247456, "current_stage_id"=>77453684, "live_standings"=>true, "coverage"=>{"predictions"=>true, "topscorer_goals"=>true, "topscorer_assists"=>true, "topscorer_cards"=>true}, "season"=>{"data"=>{"id"=>18369, "name"=>"2021/2022", "league_id"=>501, "is_current_season"=>true, "current_round_id"=>247456, "current_stage_id"=>77453684}}}, "meta"=>{"plans"=>[{"name"=>"Football Free Plan", "features"=>"Standard", "request_limit"=>"180,60", "sport"=>"Soccer"}], "sports"=>[{"id"=>1, "name"=>"Soccer", "current"=>true}]}}

I’ve been working with Rails for 2 weeks, so just finally getting that up is a big win for me. Now, I need to find my next step.

My question is, where do I look now to customize that data that’s on the page? Even if all you provide is a link or maybe help me to make sure I’m asking the right questions, that’d be helpful.

Attach An Event Handler To Add To Cart Button on a Shopify page

Our Shopify store doesn’t have a way to restrict the text characters that are entered in the gift message field so customers do not include emojis. We checked with the Bold App support team and they don’t have a way to prohibit emojis in the message box. So we decided to develop a custom solution to do it. Here is the product page.

I am thinking of attaching an event handler that gets called when Add to Cart button is clicked that strips the emojis if any in the gift message before the form is submitted. I’ve not been able to find any post here in the community that already discussed something similar so I request someone to share some ideas for me to start with after having a look at the product page. I’m trying to implement the solution found on Stackoverflow in my product page.

How to detect emoji using javascript