Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
jquery code under hidden input field is not work when we get it using jquery

I have added the field and their jquery code to get the value for that field like

<input type='hidden' name="test" id="test" value="data=$('#response').val()">

I am getting that hidden field value in jquery and splitting it by '=' but when I alert the value it shows the $('#response').val() i am expecting it to return the value of the response field type.

var val = $("#test").val();
var arr1 = val.split('=');

alert(arr1[1]);

return => $('#response').val()

expected => value of responce field.

please let me know what i am doing wrong.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

in the value attribute there will be no javascript executed, it just contains the value of the input, see https://www.w3schools.com/tags/att_value.asp or compare to onclick attribute for example. There might be some parsing with alert, but it´s general knowledge not to debug any js with alerts.

you can just set the value attribute with javascript though

below your relevant markup you could do:

$('#test').val( $('#response').val() ); // will set the value

var expected = $('#test').val(); // will output the desired value then
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!