Click here to Skip to main content
16,011,947 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a form inside that using php i am filling the textbox fields and set it to readonly.now i want to get the readonly textbox values into variables in javascript and do the validation.After loading the document i am trying to store values into variables i am getting empty string.is it possible to doing like this. please help me.Thanks in advance.

HTML
<div class="col-md-1">
						<div class="form-group">
						<label>CAPACITY</label>
						<input type="text" id="student1" name="student1" value="<?php echo $venuecapacity1;?>" readonly class="form-control">
						</div>
					</div>
					<div class="col-md-1">
						<div class="form-group">
						<label>TO BE ALLOTED</label>
						<input type="text" id="cpcty1" name="capacity1"   class="form-control">
						<input type="hidden" id="fld1" name="filled1" value="<?php echo $capacity;?>" readonly class="form-control">
						</div>
					</div>
				</div>


What I have tried:

JavaScript
<pre>$(document).ready(function(){
		debugger;
		var aloted=$("#fld1").val();
		var capacity=$("#cpcty1").val();
		var aloted2=$("#fld2").val();
		var capacity2=$("#cpcty2").val();
		var aloted3=$("#fld3").val();
		var capacity3=$("#cpcty3").val();

			$("#cpcty1").change(function(){

				alert(aloted);
				alert(capacity);
					});
				});
			</script>
Posted
Updated 23-Oct-17 4:53am
v2
Comments
Mohibur Rashid 23-Oct-17 9:01am    
Whats wrong with
$("#student1").val()?

1 solution

Try to store value in java script variables directly through php like

var simple ='<?php echo $simple; ?>'; 
 
Share this answer
 
Comments
Member 13153537 24-Oct-17 7:19am    
Finally i got a solution thanks for the help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900