Click here to Skip to main content
14,638,971 members
Rate this:
Please Sign up or sign in to 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.

<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:

<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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

var simple ='<?php echo $simple; ?>'; 
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100