Make text field empty by default

On my site, I’d like to implement a filter that allows users to filter an event based on their range. For example: there are many videos in the database (short videos or short films or feature films). I would like that the user in the field could type, for example, in the “from” field – the number 60, and in the “to” field – the number 120, and he was given films lasting from 60 to 120 minutes.

I already have certain developments. I implemented the input field using TextField. I also made restrictions on the number of characters entered (the number entered cannot be more than seven characters).

But I have a problem that by default in these fields is zero (and also zero appears after the user deletes the previously entered value). Please tell me how can I make the field empty by default.

    const MAX_DURATION = 9999999

export default function Duration() {
  const { filters, setFilters } = useContext(PageContext);
  const [minDuration, setMinDuration] = useState(filters.durationRange.start);
  const [maxDuration, setMaxDuration] = useState(filters.durationRange.end);

  useEffect(() => {
    setMinDuration(filters.durationRange.start);
    setMaxDuration(filters.durationRange.end);
  },
    [filters.durationRange.start, filters.durationRange.end]);

  useEffect(() => {
    var updatedFilters = { ...filters }
    updatedFilters.durationRange = { start: minDuration, end: maxDuration }
    setFilters(updatedFilters)
  }, [minDuration, maxDuration]);


  return (
      <div>
        <div>
          <TextField
            label="From"
            value={minDuration}
            onInput={(e) => {
              e.target.value = Math.max(e.target.value).toString().slice(0, 7)
              const newValue = Number(e.target.value)
              if (newValue) {
                setMinDuration(newValue)
              } else if (newValue == 0) {
                setMinDuration(0)
              }
            }}
          />
        </div>

        <div>
          <TextField
            label="To"
            value={maxDuration}
            onInput={(e) => {
              e.target.value = Math.max(e.target.value).toString().slice(0, 7)
              const newValue = Number(e.target.value)
              if (newValue) {
                setMaxDuration(newValue)
              } else if (newValue === 0) {
                setMaxDuration(0)
              }
              else setMaxDuration(MAX_DURATION)
            }}
          />
        </div>

      </div>
  );
}

useNavigation must be used within a data router

I am the beginner in React js and in codding so m try to open a second through the button but it’s not opening so please help me.

AliTableData.js

import React from 'react';
import { useNavigation } from 'react-router-dom';



const AliTableData = () => {
    const navigate = useNavigation()
    function AliFormData()
    {
        navigate("/AliFormData")
    }
  return (
        <div>
            <div>Home Page</div>
            <button onClick={AliFormData}>AliFormData</button>
        </div>
      
    
  )
}

export default AliTableData

AliFormData.js

import React from 'react'
import {
    CCard,CCardBody,
    CCardHeader,CCol,
    CRow,CFormInput, CFormSelect,
  } from '@coreui/react';
const AliFormData = () => {
  return (
    <div>
    <CRow>
            <CCol xs={12}>
            <CCard className='mb-12'>
            <CCardHeader>Map And Sms Config</CCardHeader>
            <CCardBody className='mb-12'>
            <CRow>
            <CCol xs={3}>
            <CFormInput type='text' className='Radius Cofig' label='Search Radius Config' size='lg' placeholder='SearchRadiusConfig'/>
            </CCol>
            <CCol xs={3}>
            <CFormInput type='text' className='BrowserMapKey' label='Browser Map Key' size='lg' placeholder='BrowserMapKey'/>
            </CCol>
            <CCol xs={3}>
            <CFormInput type='text' className='ServerMapKey' label='Server Map Key' size='lg' placeholder='ServerMapKey'/>
            </CCol>
            <CCol xs={3}>
            <CFormSelect  name="Status" size='lg' label="Sms Provider">
            <option>select givn below </option>
            <option value="1">Active</option>
            <option value="0">Inactive</option>
            </CFormSelect>
            </CCol>
            </CRow>
            </CCardBody>
            </CCard>
            </CCol>
            </CRow>
    </div>
  )
}

export default AliFormData

App.js

mport React from "react";
import AliTableData from "./AliTableData";
  
function App() {
  return (
    <div className="App">
      <h1>Hello Geeks!!!</h1>
      <AliTableData />
      
      </div>
  );
}
  
export default App;

enter image description here

this screen shows up

I just want to click on Button then it Renders on next page.

I write code and see video same but why does it show this error i don’t know actually m beginner in React

so please help me

Hosting MERN web on local server

I have developed Full Stack website recently and wanted to deploy it locally on my home server! So i need some solid information on how to do this in regard to the server installation and avoiding running database continuously from terminal.

Data Grid view with sorting , pagination and exporting

I want to implement a Grid View of data coming from Database from a Spring Controller.
View must support Pagination , Sorting and Exporting to CSV and Xls.
I do not want to write different methods to do all this stuff.
What all good Javascript ( like jquery datatables ) or Spring MVC options can i use to do this work ? Please suggest.

React Native: ScrollView of Text Components not scrolling on Android But it is working on iOS

I am using the ScrollView component in ScrollView (Main Screen) as shown in the GIF file. The problem is that this scrollView is working on iOS but not on Android Side. On an Android phone, it’s stuck and not scrolling.

ScrollView Component

<ScrollView style={{maxHeight:100,width: widthPercentageToDP('70%')}}>
      <View style={{ flexDirection: 'row', flexWrap: 'wrap', alignItems: 'flex-start', justifyContent: 'flex-start',  marginBottom: 10 }}>

        {items?.map((item) => {
          return <View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center', backgroundColor: '#e2cbff', paddingVertical: 6, paddingHorizontal: 10, marginTop: 10, marginRight: 10, borderRadius: 20, borderWidth:0.5, borderColor:'#461584'}}>
            <Text style={{ fontSize: 11, color: '#461584' }} >{item[itemKey]}</Text>
          </View>
        })}
      </View>
</ScrollView>

Main Screen View in which I am using the component.

<View>
            <Text style={styles.personalInfoTitle}>Skills/Experties</Text>
            <ChipList items={profile?.expertises} itemKey='name'/>
</View>

enter image description here

How to set up an authorization token in localStorage in Nuxt so that it disappears at the end of the browser session?

The site uses the standard nuxt authorization with the use of cookies and localstorage.

When logging in, the user has the “Remember me” checkbox, respectively, if it is disabled, it is expected to log out of the account at the end of the browser session.

The default cookie timeout is session, but using localstorage to store auth tokens at the same time leaves the user logged in.

/config/auth.js

export default {
  watchLoggedIn: true,
  strategies: {
    local: false,
    customStrategy: {
      _scheme: '~/schemes/customScheme',
      endpoints: {
        login: {
          url: '/v2/dashboard/auth/login',
          method: 'post',
        },
        logout: false,
        cookie: {
          prefix: '',
        },
        token: {
          prefix: '',
        },
        localStorage: {
          prefix: '',
        },
      },
      tokenName: 'sp-api-key',
      tokenRequired: true,
      globalToken: true,
      tokenType: '',
    },

Is there a way to set the length of storage of authorization tokens in local storage for a time equal to the browser session? Or delete authorization tokens from localStorage after the end of the browser session?

Property assignment expected error on Javascript

I am getting Property assignment expected error on Javascript. issue seems to be with onclick event

My code as follows:

Javascript:

    function submitHandler(id){     
        const textareaValue = document.getElementById(`textarea_${id}`).value;
        const content = document.getElementById(`content_${id}`); 
        const modal = document.getElementById(`modal_edit_post_${id}`);         
        fetch(`/edit/${id}`,{
            method: "POST",
            headers: {"Content-type": "application/json", "X-CSRFToken": getCookie("csrftoken")},
            body: JSON.stringify({
                content: textareaValue
            })
        })
        .then(response => response.json())
        .then(result => {
            content.innerHTML = result.data;  

            modal.classlist.remove('show');
            modal.setAttribute('aria-hidden','true');   
            modal.setAttribute('style', 'display: none');  
            
            const modalsBackdrops = document.getElementsByClassName('modal-backdrop');

            for(let i = 0; i<modalsBackdrops.length; i++){
                document.body.removeChild(modalsBackdrops[i]);
            }
        })
    }

HTML:

<button type="button" class="btn btn-primary" onclick="submitHandler({{ post.id }})">Save changes</button> 

I have checked through my function in javascript but not able to identify the source of the error

Why does using a React component for React-PDF just use the literal name instead of the real code?

I imported the react-pdf npm library

import { Page, Document } from '@react-pdf/renderer';

And then tried to use it like

<div>
     <Document file="https://bitcoin.org/bitcoin.pdf" onLoadSuccess={ this.onDocumentLoadSuccess.bind(this) }>
           <Page pageNumber={pageNumber} />
     </Document>
      <p>
            Page {pageNumber} of {numPages}
      </p>
</div>

But instead I got this output:

<document file="https://bitcoin.org/bitcoin.pdf"><page pagenumber="1"></page></document>

When I put a debugger in, it is literally converting Page to “PAGE” and Document to “DOCUMENT” strings instead of components.

I’ve used other React components installed via npm without any problem so I am wondering what could possibly be going wrong here?

SQL Bulk Query upload and read and insert to SQL- PHP

My Problem:
My .txt file reading correctly. Not showing any errors. I’m getting an error bulk assigning variables.

I Trying:
Im trying to do, Uploaded the .txt file. That file contains the bulk of SQL queries. when I upload a .txt file, I need to read and assign variables, then insert SQL.  

My Source Code with .txt File:
.txt File Screenshot

Index.php Code:

<?php ob_start();
session_start();

?>

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<form action="functions.php" method="post" name="upload_excel" enctype="multipart/form-data">
    <fieldset>
        <legend>Form Name</legend>
            <div>
               <label>Select File</label>
                  <div>
                     <input type="file" name="file" id="file">
                  </div>
            </div>
            <div>
              <label>Import data</label>
                  <div>
                     <button type="submit" id="submit" name="Import">Import</button>
                  </div>
            </div>
    </fieldset>
</form>
</body>
</html>

<?php
  ob_flush();
?>

function.php Code:

<?php ob_start();
if(!isset($result))
{
 if(isset($_POST["Import"])){
     
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$con = mysqli_connect('localhost','ABC','Welcome2023','ABC');//databse connectivity

    
    $filename=$_FILES["file"]["tmp_name"];    
     if($_FILES["file"]["size"] > 0)
     {
        $file = fopen($filename, "r");
          $getData = fgetcsv($file, 10000)
           {
             $sql = $getData;

                   $result = mysqli_query($con, $sql);
        if(!isset($result))
        {
          echo "<script type="text/javascript">
              alert("Invalid File:Please Upload SQL QUERY File.");
              window.location = "index.php"
              </script>";    
        }
        else {
            echo "<script type="text/javascript">
            alert("SQL File has been successfully Imported.");
            window.location = "index.php"
          </script>";
        }
           }
      
           fclose($file);  
     }
  }   
}
ob_flush();
?>

Trying to run a blockchain project from Github but getting error

In am trying to run a blockchain project from the github and i have follow every steps but the sign up and sign in button are not working.

Can anyone please help me to solve the problem.

Github page link – Blockchain Based Authentication

Youtube explanation of how to run project – Youtube Link, in the comment section of the video many people are getting the same error.
After the implementing the Project, i also tried to inspect the website and i got this error.

After inspecting the webpage and clicking the button on create account error

After inspecting the webpage and clicking the button on create account error – Remainig Part

I really need to implement this one and understand this project.
If anyone can help, it will be really helpful to me.
Thanks in advance.

Find unique valid numbers from inputArray

I recently came across one problem statement, The initial function was given to me with two parameters and I have write the body part. I tried to solve it and wrote some code that was working fine. However, I still couldn’t figure out what was the use of first parameter.

Here is my solution

function findUniqueValidNumbers(N, arr) {
  const uniqueNums = new Set();
  const prevIndexes = {};
  
  for (let i = 0; i < arr.length; i++) {
    const num = arr[i];
      if (!prevIndexes.hasOwnProperty(num)) {
        // If this is the first occurrence of the number, add it to the uniqueNums set
        uniqueNums.add(num);
        prevIndexes[num] = i;
      } else if (prevIndexes[num] % num === 0) {
        // If this is not the first occurrence of the number, but the index is divisible
        // by the previous occurrence index, we can add it to the uniqueNums set
        uniqueNums.add(num);
        prevIndexes[num] = i;
      } else {
        // If the index is not divisible by the previous occurrence index, we can remove
        // the number from the uniqueNums set (if it was previously added)
        uniqueNums.delete(num);
      }
  }
  
  return uniqueNums.size;
}

findUniqueValidNumbers(5, [1, 2, 1, 2, 2]) // output 1

findUniqueValidNumbers(3, [1, 2, 3]) // output 3

Problem statement

enter image description here

Integrate Web Components in React project

I am trying to integrate web components into my project. I am not adding my external JS files to index.html as there are around 10 web components I need to integrate to my react project.

I created a script instead and loaded the JS scripts in individual components.

export function loadScript(src, id) {
  return new Promise((resolve, reject) => {
    var tag = document.createElement("script");
    tag.src = src;
    tag.id = id;
    tag.className = id;
    tag.async = true;
    tag.onload = () => {
      // @ts-ignore
      resolve();
    };
    var firstScriptTag = document.getElementsByTagName("script")[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
    // }
  });
}

Adding the Script to the index.html and removing it once the component unmounts.

export default function Home() {
  useEffect(() => {
    loadScript(
      "https://rjspencer.github.io/r2wc-checklist/static/js/main.js",
      "r2wc-checklist"
    );

    return () => {
      var head = document.getElementsByTagName("head")[0];
      var scripts = head.getElementsByClassName("r2wc-checklist");
      if (scripts.length > 0) {
        head.removeChild(scripts[0]);
      }
    };
  }, []);

  return (
    <div className="home">
      Home
      <r2wc-checklist items='[{"label":"First Thing","isChecked":false}]' />
    </div>
  );
}

However, I get the following error
in Microsoft Edge

Cannot delete property ‘__reactFiber$gy95aiugunt’ of [object Object]

In Firefox

CustomElementRegistry.define: ‘r2wc-checklist’ has already been defined as a custom element

Please help me on this.
Thank you

In ReactJS, how does index.js “activate” inside index.html?

I am having some trouble with a ReactJS app on Node.js. I cannot see anywhere wherein index.js would “activate” inside of index.html. Yes there is the div with id “root” in index.html and a snippet in index.js that reads “document.getElementById(“root”)”. Also the “main” key in package.json that should point towards the index.js file. However, I wonder is there something else that should trigger index.js to “activate” inside index.html, wherein index.js would render app.js.

I have searched for different places that may enact the index.js file inside my index.html but I cannot find anything. I get a blank page. I think I am getting a blank page because the index.js is not being read by the client browser. It is “disconnected” from index.html so to speak.

For reference I am making a ReactJS app on Node.js, I am using CPanel on an nginx server.
If anyone has any advice I would appreciate it.

how to create a bullet in the middle of the screen [closed]

how to create a bullet in the middle of the screen when i press the fire button . should i use raycasting or something to do
enter image description here
and how to make a particle effect like this image when i press fire button
I Just need the illustrative example doesn’t have to be the same as the photo
enter image description here

I need example code about that
Please help me
Thanks so much

How do I modify the height and width of the PDF being show in `react-pdf` using tailwind?

I’m trying to render a PDF through react-pdf to a certain width and height. How can I do this by using Tailwind classes? In the screenshot attached, you can see that the PDF is so much bigger than one of the components, which is the same component I want it to be the same size of. enter image description here

Here’s the code I’m currently using for the PDF render:

<>
<Document file={pdfUrl}>
            <Page
                pageNumber={1}
                className="h-24 w-10 border-solid border-2 border-sky-500"
            />
        </Document>
<>