Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 09, 2012, 08:31:48 PM

Pages: [1]   Go Down
  Print  
Author Topic: passing a radio button var value to another var  (Read 1226 times)
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« on: March 10, 2010, 07:39:57 AM »

I am having a hard time passing a var name to another var so i can use it throughout the site

im getting the original variable from a radio button, i want to take that var pass it to a $name and then use that $name anywhere on the site on any page.

Code:
<form name="radioemail">
<input type="radio" name="chkmailext" value=".com"  onclick="getradioval()"
 />.com &nbsp;
<input type="radio" name="chkmailext" value=".net" onclick="getradioval()" />.net &nbsp;
<input type="radio" name="chkmailext" value=".org" onclick="getradioval()" />.org &nbsp;
<input type="radio" name="chkmailext" value=".biz" onclick="getradioval()" />.biz &nbsp;
<input type="radio" name="chkmailext" value=".ca" onclick="getradioval()" />.ca
</form>
 Please select your proper email extension.<br />
 Only those extensions listed will be accepted.
</div>
<script type="text/javascript">
function getradioval()
 {
       for (var i=0;i<document.radioemail.chkmailext.length;i++)
       {
         if (document.radioemail.chkmailext[i].checked)
               {
              var rbgroup = document.radioemail.chkmailext[i].value;
                }
        }
}

</script>



so from this rbgroup holds the value i want (and by the way that alert in this function does not work) i get a page error every time i click on the button..

anyway back to the var
so how do i pass rbgroup to a $name and use it anywhere in the site, i have tried putting $rbgroup, rbgroup, $name = rbgroup  and i know that rbgroup has a value because i tested it.   but nothing works no matter what i choose i cannot get the var to pass its info..

i guess what do i put after the function to get the val inside a  $name so i can use it


it also tells me that my radio form is null and not an object, thats the page error i get


and i did change the form to read this

Code:
<form name="radioemail" action="" onsubmit="return getradioval()">]

but it still tells me that document.radioemail.chkmailext is null and is not an object
« Last Edit: March 10, 2010, 08:07:13 AM by durangod » Logged
scanman20
Über Jedi
*****
Offline Offline

Posts: 1520



WWW
« Reply #1 on: March 10, 2010, 11:29:29 AM »

The only way to persist data with JavaScript would be to either use cookies to store and retrieve data on the client side or to add your variable to any links on your page and then read them back in on other pages from the URL. JavaScript doesn't prefix its variables with any symbols like PHP does with $. I threw an alert statement in your function and it worked fine so I don't know what your issue is there. Did you want the form to do something when the user makes a selection? If so, what?
Logged

Even a broken clock is right twice a day.
NotOneBit.com
MCSE - MCSA - MCP
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #2 on: March 10, 2010, 01:09:39 PM »

hi thanks yeah no problem in the form process just trying to grab the value and use it..

http://www.lunarforums.com/web_site_management/email_content_checker_not_working-t54797.0.html

that link will catch you up on whats going on

basically at first i wanted to use indexOf to catch if someone did not put .com .net .org .biz or .ca in their email when they registered  but i was told that it did not cover if someone typed in spam@mail.com.cr   something like that   

so then we worked on trying to catch the last 4 of the string using substr, which would have worked perfect  but due to this freaken non standardization between ie and ff, a string like 12345.com using a substr -4 in ie shows 1234 and ff shows .com (which is what i want .com)    so i cant use substr


so then i thought ok i just do some radio buttons for .com .net and so on and have the user select...

and hve them just type in the email as myemail@yahoo and then patch the two strings together, thats why i needed the value off the radio var
Logged
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #3 on: March 10, 2010, 02:37:08 PM »

i got it working thanks so much
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: