vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   onchange event help needed... (https://vborg.vbsupport.ru/showthread.php?t=82429)

Cloudrunner 06-02-2005 11:24 PM

onchange event help needed...
 
I need to have two variables get assigned when a user changes the setting of a select box. I'm not sure how to do this, but I am thinking that the onchange value in select can do what I am looking for it to do.

i.e. I have one select box
HTML Code:

<select name="whatever" onchange="*something here*">
<option>Option1</option>
<option>Option2</option>
</select>

and have it set two variables $x and $y to a default value just in case the user doesn't change the selection, while if the user does change the selection, then both the variables $x and $y change accordingly for each option.

I'm not a javascript guru, so I don't know how to do this, if anyone can assist here I would appreciate it. I don't want to have two select inputs on this...

Thank you!

)O( Cloudrunner )O(

this needs to be done without reloading the page, and in a form name=variable system so that I can pass that information to the next script via the $_POST variable...

anyone?

Anyone...Truth is I'm Javascript stupid folks, and I have not a CLUE on how to get this to work properly....

I have this thus far, and while it works in a standalone presence, when I try to add it to other pages, it chokes and I get nothing...

This is the test page...
PHP Code:

 <script language="javascript"> 
function makeAmount(){ 
    var selVal = document.donate.currency_code[document.donate.currency_code.selectedIndex].value; 
    if (selVal == 'USD') document.donate.amount.value = 5; 
    else if (selVal == 'AUD') document.donate.amount.value = 10; 
    else if (selVal == 'CAD') document.donate.amount.value = 15; 

</script> 
<? 
if (empty($_POST)){ 
?> 
<form name="donate" action="test.php" method="post"> 
    <input type="hidden" name="amount" value="1"> 
    <select name="currency_code"> 
        <option value="USD">US Dollar $5</option> 
        <option value="AUD">Australian Dollar = $10</option> 
        <option value="CAD">Canadian Dollar = $15</option> 
    </select> 
    <input type="submit" onClick="makeAmount()"> 
</form> 
<? 
} else { 
    echo $_POST['currency_code']." -- ".$_POST['amount']; 

?>

Like I said, when I run this it works fine, but when I try to go live with it on a real page with true html / xml constructs, it chokes, no errors, but the "amount" variable is not passed within the $_POST global as if the form wrote it which is what I need to do...

Any help is appreciated...

Thanks

)O( Cloudrunner )O(

Cloudrunner 06-05-2005 03:48 AM

Quote:

Originally Posted by Cloudrunner
I need to have two variables get assigned when a user changes the setting of a select box. I'm not sure how to do this, but I am thinking that the onchange value in select can do what I am looking for it to do.

i.e. I have one select box
HTML Code:

<select name="whatever" onchange="*something here*">
<option>Option1</option>
<option>Option2</option>
</select>

and have it set two variables $x and $y to a default value just in case the user doesn't change the selection, while if the user does change the selection, then both the variables $x and $y change accordingly for each option.

I'm not a javascript guru, so I don't know how to do this, if anyone can assist here I would appreciate it. I don't want to have two select inputs on this...

Thank you!

)O( Cloudrunner )O(

this needs to be done without reloading the page, and in a form name=variable system so that I can pass that information to the next script via the $_POST variable...

anyone?

Anyone...Truth is I'm Javascript stupid folks, and I have not a CLUE on how to get this to work properly....

I have this thus far, and while it works in a standalone presence, when I try to add it to other pages, it chokes and I get nothing...

This is the test page...
PHP Code:

 <script language="javascript"> 
function makeAmount(){ 
    var selVal = document.donate.currency_code[document.donate.currency_code.selectedIndex].value; 
    if (selVal == 'USD') document.donate.amount.value = 5; 
    else if (selVal == 'AUD') document.donate.amount.value = 10; 
    else if (selVal == 'CAD') document.donate.amount.value = 15; 

</script> 
<? 
if (empty($_POST)){ 
?> 
<form name="donate" action="test.php" method="post"> 
    <input type="hidden" name="amount" value="1"> 
    <select name="currency_code"> 
        <option value="USD">US Dollar $5</option> 
        <option value="AUD">Australian Dollar = $10</option> 
        <option value="CAD">Canadian Dollar = $15</option> 
    </select> 
    <input type="submit" onClick="makeAmount()"> 
</form> 
<? 
} else { 
    echo $_POST['currency_code']." -- ".$_POST['amount']; 

?>

Like I said, when I run this it works fine, but when I try to go live with it on a real page with true html / xml constructs, it chokes, no errors, but the "amount" variable is not passed within the $_POST global as if the form wrote it which is what I need to do...

Any help is appreciated...

Thanks

)O( Cloudrunner )O(

NVM, got it figgered out.


All times are GMT. The time now is 01:06 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01143 seconds
  • Memory Usage 1,742KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete