Skip to main content
added 87 characters in body
Source Link
loparr
  • 906
  • 1
  • 14
  • 42

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you. I need it to work as smooth as this without reloading http://jsfiddle.net/eWXUT/3/

EDIT: I put the code on livesite but it is not working http://www.vypadavanie.net/ako-rychlo-rastu-vlasywww(dot)vypadavanie(dot)net/ako-rychlo-rastu-vlasy?

In drupal 7 had to wrap the code inside jQuery(document).ready(function($) as well

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you. I need it to work as smooth as this without reloading http://jsfiddle.net/eWXUT/3/

EDIT: I put the code on livesite but it is not working http://www.vypadavanie.net/ako-rychlo-rastu-vlasy?

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you. I need it to work as smooth as this without reloading http://jsfiddle.net/eWXUT/3/

EDIT: I put the code on livesite but it is not working www(dot)vypadavanie(dot)net/ako-rychlo-rastu-vlasy?

In drupal 7 had to wrap the code inside jQuery(document).ready(function($) as well

added 109 characters in body
Source Link
loparr
  • 906
  • 1
  • 14
  • 42

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you. I need it to work as smooth as this without reloading http://jsfiddle.net/eWXUT/3/

EDIT: I put the code on livesite but it is not working http://www.vypadavanie.net/ako-rychlo-rastu-vlasy?

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you. I need it to work as smooth as this without reloading http://jsfiddle.net/eWXUT/3/

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you. I need it to work as smooth as this without reloading http://jsfiddle.net/eWXUT/3/

EDIT: I put the code on livesite but it is not working http://www.vypadavanie.net/ako-rychlo-rastu-vlasy?

added 84 characters in body
Source Link
loparr
  • 906
  • 1
  • 14
  • 42

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you. I need it to work as smooth as this without reloading http://jsfiddle.net/eWXUT/3/

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you.

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you. I need it to work as smooth as this without reloading http://jsfiddle.net/eWXUT/3/

Source Link
loparr
  • 906
  • 1
  • 14
  • 42
Loading