0

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 );

}

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks - that was it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.