Passing values from html to javascript example

So, basically, the following examples sets values in javascript functions.

In the first function, we set up a function called “myMsg” and in parenthesis we put a placeholder for a value. We give that placeholder a value from one of the html elements. We do this by setting the html input element to reference “form.text1.value”. This comes from the parent object, “form” in this case. Then the value of the “name” attribute within the input element that we want to look at. Then we say “value”, which says “pull the value of” the element we’ve looked at.

So, we type something in the text field and hig Show Me. We get an alert that contains what we entered into the text field. Upon typing something in that field, we gave it a value. The javascript function contains code that says “give me an alert” and that alert will contain the value the user puts in the field.

Similarly, the second function contains code that says “set the document background to what the user types in the field”.

def my_javascript_snippet
  blog_post.should(be_highlighted)
end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s