Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How can I make this field pre - selected?

Posted on 2011-05-03
18
Medium Priority
?
469 Views
Last Modified: 2012-08-13
Hi There, On this site here
http://www.smokinhot.com.au/Go-through-checkout-process?redirected=1

If you select new user - you will see there is a user field that has NEWSLETTER - How can I make this preselected?

There isn't an option in the user field managment?

Thanks,
0
Comment
Question by:Amanda Watson
  • 8
  • 4
  • 3
  • +1
17 Comments
 
LVL 8

Expert Comment

by:austega
ID: 35517597
Mmm... I am redirected to http://www.smokinhot.com.au/View-your-cart-content when I click on your link - and cannot see a New User link/button.


In any case what extension etc are you using to gather the new user info including newsletter option?
0
 
LVL 11

Author Comment

by:Amanda Watson
ID: 35517659
No extension, its just virtuemars user fields
0
 
LVL 11

Author Comment

by:Amanda Watson
ID: 35517666
just go to the shop add some items to your cart and proceed to checkout to see the new user section where you will see the newsletter field...i want it pre-selected
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Mark Brady
ID: 35517697
Do you mean the check box next to "Newsletter? If you want that checked by default just add the word "checked" to it.


Here is a sample.

<input type="checkbox" name="sample" checked />

The word checked will put a checkmark in the box.
0
 
LVL 11

Author Comment

by:Amanda Watson
ID: 35517707
Where would I do this though?
This is dynamically generated somehow...?
0
 
LVL 20

Accepted Solution

by:
Mark Brady earned 1800 total points
ID: 35517810
Well you could do it through javascript. If you have access to the page to could check the box on page load.. Something like this will do it.

<html>
<head><TITLE>JScript</TITLE>
<script language="javascript">
function checkMe()
{
document.getElementById('newsletter').checked = true;
}
</script>
</head>
<body onload="checkMe()">
<center>
<form>
Newsletter <input type="checkbox" id="newsletter" name="newsletter" /> Uncheck for no newsletter<br />
</form>
</center>
</body>
</html>


That's a sample of how to do it. Just copy the javascript section and paste that into the <head> section of your page. The tricky part is, you must get the "id" name of that checkbox. Right click and view source will show you what the id is called.

0
 
LVL 8

Expert Comment

by:austega
ID: 35517875
Mmm... good question. I agree there doesn't seem to be any ability to use VM user field parameters - I would expect someone has documented a work around on the VM forums.
0
 
LVL 22

Assisted Solution

by:remorina
remorina earned 200 total points
ID: 35517900
Hi snowball77,
I see that mootools is present in the template, so you can easily check this using mootools, you can auto check this control using its rendered ID.

You also have a theme.js located here
http://www.smokinhot.com.au/components/com_virtuemart/themes/smokin/theme.js

Try adding the below code at the bottom of this file and let me know how it goes.
window.addEvent('domready', function() {
if ($('vm_newsletter_field')) {
$('vm_newsletter_field').checked=true;}
});

Open in new window


Cheers!
0
 
LVL 22

Expert Comment

by:remorina
ID: 35518070
Might be a better idea to place the above code in this file instead as it already has a mootools function and it comes after the loading the mootools-release-1.11.js
http://www.smokinhot.com.au/components/com_virtuemart/js/mootools/mooPrompt.js

Cheers!
0
 
LVL 11

Author Comment

by:Amanda Watson
ID: 35574867
Hi, just checking remorina, but that code here:
window.addEvent('domready', function() {
if ($('vm_newsletter_field')) {
$('vm_newsletter_field').checked=true;}
});

addded to http://www.smokinhot.com.au/components/com_virtuemart/js/mootools/mooPrompt.js

Is all i need to do to make that work?

Is that the correct field name...?  
0
 
LVL 20

Expert Comment

by:Mark Brady
ID: 35583319
did you try my suggestion yet? All you need to do is drop that javascript function into the page and change the id to the id of the checkbox and it will check the box when the page is loaded. Pretty simple to do!
0
 
LVL 22

Expert Comment

by:remorina
ID: 35608601
@snowball77:
Yes, it should suffice to make it checked and the checkbox name is "vm_newsletter_field" as used in the code.

I've tested direct execution and it and it worked but you will need to try it yourself and see if it sucessfully executes or causes any errors, hopefully it shouldn't.

And the file mooPrompt.jos you pointed is the correct file you should place the block in, just make sure you add it at the bottom of the file after all other functions.

Cheers!
0
 
LVL 11

Author Comment

by:Amanda Watson
ID: 35665930
remorina..that worked thanks.
elvin I am sure yours would work too I just took the easiet option here!
Thank you
0
 
LVL 11

Author Comment

by:Amanda Watson
ID: 35695085
eww slight problem, this pre selected trick doesn't seem to be working in IE???
0
 
LVL 11

Author Comment

by:Amanda Watson
ID: 35695117
Looks like elvin66 solution worked for all browsers....
Sorry I need to change the point allocation
0
 
LVL 20

Expert Comment

by:Mark Brady
ID: 35695625
Thanks Snowball. I knew it would work as I have used it myself but I'm glad you got it working.
0
 
LVL 11

Author Closing Comment

by:Amanda Watson
ID: 35701991
Ta
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question