Reputation: 2963
I have an HTML form with input fields. I am trying to get the data from the input fields to be passed to a javascript function for processing. I am trying to get the value of "tenantid" but the only thing I get, when displaying the value in the popup:
first objectHMTLFormElement
How can I get values entered in the form to the Javascript code?
TIA
I have: testing.blade.php
<script type="text/javascript" src="{{ URL::asset('js/test.js') }}">
</script>
[.. snip ..]
<form id="oogie" class="form-horizontal" role="form" method="POST" action="{{ url('') }}/dashboard">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('tenantid') ? ' has-error' : '' }}">
<label for="tenantid" class="col-md-4 control-label"> Tenant ID </label>
<div class="col-md-6">
<input id="tenantid" type="integer" class="form-control" name="tenantid" value="{{ old('tenantid') }}" required autofocus>
@if ($errors->has('tenantid'))
<span class="help-block">
<strong>{{ $errors->first('tenantid') }}</strong>
</span>
@endif
</div>
</div>
</form>
[... snip ...]
<button class="ClickMe" onclick="testme();">Click me</button>
test.js
function testme()
{
alert("got in");
var parameters = document.getElementById("oogie");
alert("first " + parameters );
}
Upvotes: 0
Views: 2498
Reputation: 391
That's because your script isn't trying to access the value of the field, but the field itself.
You should use document.getElementById(ID).value
. This will fix your issue.
Upvotes: 1