By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

javascript breaks when element not visible... :(

P: 7
Hello,

I'm using a javascript function to pass the values of various form elements. The problem is that the script breaks when I'm trying to retrieve a value of an element that is not visible, because of category/subcategory dependency.

The function is:
Expand|Select|Wrap|Line Numbers
  1.     <script language="JavaScript">
  2.     function reloadF(f)
  3.     {    
  4.         var catV = document.getElementById('cat');
  5.         var subcatV = document.getElementById('subcat');
  6.         var priceV = document.getElementById('priceID'); // depends on category
  7.         var priceRentV = document.getElementById('priceRentID'); // depends on category
  8.  
  9.         location.href = 'file.php?catV=' + catV.value + '&subcatV=' + subcatV.value + '&priceV=' + priceV.value + '&priceRentV=' + priceRentV.value;
  10.       </script>
  11.  
in the form:
Expand|Select|Wrap|Line Numbers
  1. <select id="cat" onchange="reloadF(this.form)" ...>
  2. <select id="subcat" onchange="reloadF(this.form)" ...>
  3.  
  4. if ($_GET['catV'] == 3)
  5.     <input type="text" id="priceID" value="$_GET['priceV']" ...>
  6.  
  7. if ($_GET['catV'] != 3)
  8. <input type="text" id="priceRentID" value="$_GET['priceRentV']" ...>
  9.  
Thank you.
Nov 7 '07 #1
Share this Question
Share on Google+
2 Replies


P: 7

Found it, just after the post... :)
I needed to use hidden elements, like:

Expand|Select|Wrap|Line Numbers
  1. if ($_GET['catV'] == 3)
  2.     <input type="text" id="priceID" value="$_GET['priceV']" ...>
  3. else
  4.    <input type="hidden" id="priceID" ...>
  5.  
  6.  
Thank you.
Thanks again. ....................................
Nov 7 '07 #2

acoder
Expert Mod 15k+
P: 16,027
Found it, just after the post... :)
How many times does that happen? At least the :( became a :) !
Nov 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.