How to pass Variable from External JavaScript to HTML Form

后端 未结 2 636
北荒
北荒 2021-01-29 13:46

I have been trying to pass a value from an external javascript file to an HTML form with no luck. The files are rather large so I am not sure I can explain it all but ill try.

2条回答
  •  悲&欢浪女
    2021-01-29 14:24

    Your HTML file needs to reference the JavaScript js file. Have a function in your JavaScript that returns the value that you need. Use JavaScript (I like jQuery) to set the form field to what you need.

    JS file:

    
    

    HTML file:

    Ad Code:

    Although, really, this might do what you want (depending on what you are trying to do):

    Ad Code:

提交回复
热议问题