passing variable to a function - vbscript

its kind of silly question. but i dont know what mistake i am making. if any one could help.
<html>
<head>
<script type="text /vbscript">
function zips(s)
document.write(s)
end function
</script>
</head>
<body>
<script type="text/vbscript">
dim x,y
x="sushant"
<button onclick="zips(x)" id=button1 name=button1>clickme</button>
</script>
</body>
</html>
sorry i dont know how to format it. but i am no getting the desired output. any help is very much appreciated

Your button tag should be outside of the script tag.
<script type="text/vbscript">
dim x,y
x="sushant"
</script>
<button onclick="zips(x)" id=button1 name=button1>clickme</button>
The button is not part of the script but part of the HTML.

Related

How to change the language of new Captcha-Recaptcha

Can anyone give me an example about to change to italian ReCaptcha questions and answers?
I found the following code:
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=it" />
But no idea where to put it and all attempts to place it on my contact form failed.
It always speaks english only.
Thanks in advance
Script tags usually go in the head section, between the <head> and </head> tags, or just before the body closing tag, </body>.
However, you also need to add a tag in the form for the ReCaptcha to be show.
This code will display the ReCaptcha in Italian:
<html>
<head>
<title>reCAPTCHA demo: Simple page</title>
<script src="https://www.google.com/recaptcha/api.js?hl=it" async defer></script>
</head>
<body>
<form action="?" method="POST">
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
<br/>
<input type="submit" value="Submit">
</form>
</body>
</html>
You need to replace the data-sitekey attribute with your own API sitekey.

AJax will not display a text file onto the screen?

I am new to AJAX and am experimenting with a simple page that should show a txt file into a specific location. At this point it does not show the vlist.txt file.
Question: Why does this code not display the file (vlist.txt)?
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load("C:\Users\itpr13266\Desktop\vlist.txt");
});
});
</script>
</head>
<body>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2>This is where your text will go</div>
<button>Get External Content</button>
</body>
</html>
New Code that was Tried.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").load(function() {alert( "Load was performed." ););
});
});
</script>
</head>
<body>
<div id="div1"><h2>Let jQuery AJAX Change This Text</h2>This is where your text will go</div>
<button>Get External Content</button>
</body>
</html>
No alert box was displayed so I am not sure that it is even getting to that point.
$().load() can't be used with a local file path like C:\Users\itpr13266\Desktop\vlist.txt.
Put your file on a web server and your code will most likely work.

Setting onclick dynamically and passing in the element itself

element.onclick= aFunction() does not call the function when element (in this case a <SPAN> element) is clicked.
This question has been answered for JavaScript (question by Nick Van Hoogenstyn), but how do you do the same sort of thing for VBScript? The reason why I'm using VBScript instead of JavaScript is that I'm creating an HTA and using VBScript for the file access activities within it.
This
demonstrates that this simple code:
<html>
<head>
<Title>spanclick</Title>
<hta:application id="spanclick" scroll = "no">
<script type="text/vbscript">
Function onSpanClick(oElm)
MsgBox oElm.tagName & " onSpanClick clicked"
End Function
</script>
</head>
<body>
<span onclick="onSpanClick Me">onSpanClick</span>
</body>
</html>
'works' by putting the function name into the onclick attribute of the span element and passing the element (Me) to the function.
VBScript is little bit different form Javascript in Syntax
see the sample
<script language="vbscript">
sub cmdBtn_Click()
msgbox("Click!!!")
end sub
</script>
<input type="button" name="cmdBtn" value="Click Me!" onclick ="vbscript:cmdBtn_Click">

mootools Scrollable not working

I used mootools scrollable(http://mootools.net/forge/p/scrollable) on my page,but it is not working.
my page: http://neyriz.net/moo/
I used it for div with id="right"
why it's not work?
You are making 2 mistakes. The first is that you try to instanciate the Scrollable before the DOM is ready and so your element doesn't exist. So you have to move your script tag either to the end of the body or you wrap it in an event listener. I.E:
window.addEvent('domready', function() {
var myScrollable = new Scrollable($('right'));
});
The second problem is that the plugin has some dependencies. In this case you need to include Slider, Element.Measure, Element.Shortcuts from MooTools more. You can go to http://mootools.net/more/ and select those 3 modules. Download the file and include it into your head between mootools-core and scrollable:
<script type="text/javascript" src="mootools-core.js"></script>
<script type="text/javascript" src="mootools-more.js"></script> INSERT MOOTOOLS MORE HERE!
<script type="text/javascript" src="scrollable.js"></script>
In general it's better when you define and load your JS files before the body. So it looks like:
<html>
<head><title>My awesome page</title></head>
<body>
<h1>My awesome page</h1>
<p>Some text</p>
<script type="text/javascript" src="mootools-core.js"></script>
<script type="text/javascript" src="mootools-more.js"></script> INSERT MOOTOOLS MORE HERE!
<script type="text/javascript" src="scrollable.js"></script>
</body>
</html>

How to append a new node in Hpricot

I have a DOM and I want to insert a new node using Hpricot. Here my DOM structure:
<html>
<head>
</head>
<body>
...
...
</body>
</html>
What I want is I have to insert a script tag as a last child of <body> something like:
<body>
...
<script>
console.log(document.cookie)
</script>
</body>
This is what I have:
doc = Hpricot.XML(%{<html>
<head>
</head>
<body>
...
...
</body>
</html>
})
doc.at('body')
But now I'm not getting any desired method to move forward and the documentation of hpricot sucks. Has anyone done this before?
Achieved but using Nokigiri pasting it incase if someone want to do this
Here the HTML
h1 = Nokogiri::XML.parse %{<html>
<head>
<script>
alert("hello");
</script>
</head>
<body>
<p> THIS IS WAR </p>
</body>
</html>}
apend your tag (my case script tag) as last child of body
h1.search('body').children.after(%{<script> alert ('Hello') </script>})
Hope this help to some

Resources