Results 1 to 9 of 9

Thread: Drop Down list problem, onchange

  1. #1
    Join Date
    Jan 2004

    Drop Down list problem, onchange

    I have a drop down list called "Number_Of_Carts". It has a # selection from 1-9. What I want is, when they click on any number, I want them to go to the same .php script file to pull further data based on the # they chose. It refreshes the page, but it doesn't hold the value! It just come back with first option selected which is an empty option. How can I make it refresh to:
    PHP Code:
    mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>
    Which is my link. Then hold the value of what they selected. So if they choose 4 for instance, then the php code will pull the data from the variable $Number_Of_Carts, so then my script states, if 4 is selected then write "selected" so then the page with refresh with the "4". I hope I made this clear.

    PHP Code:
    <td width="175" height="25"><font size="2"># of Carts:</font></td>
    <td width="427" height="25">
    <select name="Number_Of_Carts" onchange="if(this.options[this.selectedIndex].id){top.location.href=this.options[this.selectedIndex].id;}return true;">
    <option selected></option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>" value="1">1</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>" value="2">2</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>" value="3">3</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>" value="4">4</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>" value="5">5</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>" value="6">6</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>" value="7">7</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>" value="8">8</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>" value="9">9</option>

  2. #2
    Join Date
    Jul 2004
    Canada, eh
    If I were trying to submit info, I'd use a form. something like this:
    <td width="175" height="25"><font size="2"># of Carts:</font></td> 
    <td width="427" height="25">
    <form action="mobile_vendors_pre_submit.php"> 
    <input type="text" name="state" style="display:none" value="<?php echo ($_GET['state']?$_GET['state']:"0"); ?>"></input>
    <select name="Number_Of_Carts" method="GET" onchange="if(this.selectedIndex>0) this.form.submit();"> 
    <option >- Choose -</option>
    <option value="1" <?php echo ($_GET['Number_Of_Carts']==1?"selected='true'":""); ?>>1</option> 
    <option value="2" <?php echo ($_GET['Number_Of_Carts']==2?"selected='true'":""); ?>>2</option> 
    <option value="3" <?php echo ($_GET['Number_Of_Carts']==3?"selected='true'":""); ?>>3</option> 
    <option value="4" <?php echo ($_GET['Number_Of_Carts']==4?"selected='true'":""); ?>>4</option> 
    <option value="5" <?php echo ($_GET['Number_Of_Carts']==5?"selected='true'":""); ?>>5</option> 
    <option value="6" <?php echo ($_GET['Number_Of_Carts']==6?"selected='true'":""); ?>>6</option> 
    <option value="7" <?php echo ($_GET['Number_Of_Carts']==7?"selected='true'":""); ?>>7</option> 
    <option value="8" <?php echo ($_GET['Number_Of_Carts']==8?"selected='true'":""); ?>>8</option> 
    <option value="9" <?php echo ($_GET['Number_Of_Carts']==9?"selected='true'":""); ?>>9</option> 
    <input type="submit" value="Submit"></input>
    Kids, kids... you tried your best, and you failed miserably; the lesson is: never try.

  3. #3
    Join Date
    Jan 2004
    Here is what I have now:

    PHP Code:
    <select name="Number_Of_Carts" onchange="this.form.submit();">
    <option selected></option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>&carts=1" value="1">1</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>&carts=2" value="2">2</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>&carts=3" value="3">3</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>&carts=4" value="4">4</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>&carts=5" value="5">5</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>&carts=6" value="6">6</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>&carts=7" value="7">7</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>&carts=8" value="8">8</option>
    <option id="mobile_vendors_pre_submit.php?state=<? $state = $_GET['state']; echo $state; ?>&carts=9" value="9">9</option>
    I need it to go to those specified url because the $carts are being read by an include to see if it needs to add more input field, and how many. How can I use the onchange submit form but with the url in the "id" specified by each number!?

  4. #4
    Join Date
    Jan 2004
    I need something like:
    PHP Code:
    but with onchange submit form to the specified "id" url, as if say it was just a regular submit button with form action to the url, but with more than one url option, I need it like this otherwise my data won't pass thru. If I do onchange submit, it parses the data, but doesn't go the the url, just stays in the same place!

  5. #5
    Join Date
    Jan 2004
    Can anyone help, i'm real desperate!

  6. #6
    Join Date
    Jan 2003
    I'm completely unclear on this question. You want to refresh the current page with a query string which has a value based on what selection is made in a select box?

     <select size="1" onchange="location.href=location.href+'?Number_of_Carts='+this.options[this.options.selectedIndex].value">
     <option value="1">One</option>
     <option value="2">Two</option>
     <option value="3">Three</option>
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  7. #7
    Join Date
    Jan 2004
    Thanx anyways.
    Last edited by d.brandusa; 09-11-2004 at 02:49 PM.

  8. #8
    Join Date
    Jan 2003
    I'm sorry but this is too complicated for my little brain. It makes absolutely no sense to me...Sorry.
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  9. #9
    Join Date
    Sep 2004
    Here is your code:
    PHP Code:
    <select name="Number_Of_Carts" onchange="this.form.submit();"> 
    <option id="mobile_vendors_pre_submit.php?state=<?= $_GET['state']?>&carts=1" value="1" <?php ($_GET['Number_Of_Carts']==1? echo 'selected':''); ?>>1</option> 
    <option id="mobile_vendors_pre_submit.php?state=<?= $_GET['state']?>&carts=2" value="2" <?php ($_GET['Number_Of_Carts']==2? echo 'selected':''); ?>>2</option> 
    <option id="mobile_vendors_pre_submit.php?state=<?= $_GET['state']?>&carts=3" value="3" <?php ($_GET['Number_Of_Carts']==3? echo 'selected':''); ?>>3</option> 
    <option id="mobile_vendors_pre_submit.php?state=<?= $_GET['state']?>&carts=4" value="4" <?php ($_GET['Number_Of_Carts']==4? echo 'selected':''); ?>>4</option> 
    <option id="mobile_vendors_pre_submit.php?state=<?= $_GET['state']?>&carts=5" value="5" <?php ($_GET['Number_Of_Carts']==5? echo 'selected':''); ?>>5</option> 
    <option id="mobile_vendors_pre_submit.php?state=<?= $_GET['state']?>&carts=6" value="6" <?php ($_GET['Number_Of_Carts']==6? echo 'selected':''); ?>>6</option> 
    <option id="mobile_vendors_pre_submit.php?state=<?= $_GET['state']?>&carts=7" value="7" <?php ($_GET['Number_Of_Carts']==7? echo 'selected':''); ?>>7</option> 
    <option id="mobile_vendors_pre_submit.php?state=<?= $_GET['state']?>&carts=8" value="8" <?php ($_GET['Number_Of_Carts']==8? echo 'selected':''); ?>>8</option> 
    <option id="mobile_vendors_pre_submit.php?state=<?= $_GET['state']?>&carts=9" value="9" <?php ($_GET['Number_Of_Carts']==9? echo 'selected':''); ?>>9</option> 
    This should work

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11554 seconds
  • Memory Usage 2,965KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (9)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates