Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 715521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:11:47+00:00 2026-05-14T05:11:47+00:00

Inside my index.html.erb <script type= text/javascript> var msg = Hello World ; </script> i

  • 0

Inside my index.html.erb

<script type= "text/javascript">
  var msg = "Hello World" ;
</script>

i need pass this var msg to my controller say get_variable() method in my Post controller.

Edit : get javascript variable msg in same index.html.erb as ruby variable
Thanks in Advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:11:48+00:00Added an answer on May 14, 2026 at 5:11 am

    Try this

    <%= link_to_remote, 'Message', :url=>{:controller=>'controller_name', :action=>'method_name'}, :with=> "'msg='+msg" %>
    

    controller_name.rb

    def method_name
      @message= params[:msg]
      puts @message # >> should be print "Hello World"
    
    end
    

    EDITED

    <%= link_to_remote, 'Message', :url=>{:controller=>'controller_name', :action=>'method_name'}, :with=> "'msg='+msg" %>
    <div id ='show_message'></div>
    

    controller_name.rb

    def method_name
      @message= params[:msg]
      render :update do|page|
        page.replace_html 'show_message', @message
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Inside http://mydomain1.com/index.html <html> <body> <script type=text/javascript> var a = 1; </script> <iframe src=http://domain2.com/test2.html></iframe> </body>
I include myscript.js in the file http://site1.com/index.html like this: <script src=http://site2.com/myscript.js></script> Inside myscript.js, I
I have 3 files: index.html.erb is my homepage inside the index I render a
inside index.html.erb there is the following code <video width=320 height=240 controls=controls> <source src=truffle1.mp4/> Your
I've got 2 HTML files and 1 javascript file, index.html, results.html and file.js Inside
i'm loading external contents inside a page with .load() . in my index.html i
I have an index.html file which looks like this (the rest is omitted), <ul
While using Rails ActionMailer with Multipart Emails I created both: approve_trade_email.html.erb AND approve_trade_email.text.erb I
I have a index.html file which loads html files. $('#content').load(url,function() {}); Inside those html
I have the following frame: <iframe src=http://www.eggsandbacon.jquery.js></iframe> Inside my index.html document. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.