3 Replies - 364 Views - Last Post: 16 May 2012 - 10:25 AM

#1 skirkpatrick  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 62
  • Joined: 18-February 08

How to grab values that are greater > '' and make new vari

Posted 15 May 2012 - 12:41 PM

I am completely new to client side scripting and am a little lost.

I have a user filled form with 13 dropdown lists - the user can pick a maximum of eight values out of the possible 13 dropdowns. I am able to capture the values using document.getElementById("form_line_0_1_1").value, what I am looking to do is to create 8 different variables that I can then use to reformat the text based upon the users selections.

Any help or direction would be greatly appreciated.

Steve

Is This A Good Question/Topic? 0
  • +

Replies To: How to grab values that are greater > '' and make new vari

#2 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon

Reputation: 5421
  • View blog
  • Posts: 8,706
  • Joined: 19-March 11

Re: How to grab values that are greater > '' and make new vari

Posted 15 May 2012 - 12:45 PM

Moved this to Javascript, where you'll probably get better results.
Was This Post Helpful? 0
  • +
  • -

#3 skirkpatrick  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 62
  • Joined: 18-February 08

Re: How to grab values that are greater > '' and make new vari

Posted 16 May 2012 - 06:28 AM

I was hoping someone might be able to help me - I know how I would do it server side but that is not an option in this case. But it appears that I have to write some complex code to get it to work. Basically it the first dropdown is selected then it becomes var1 if not look to the second dropdown and see if it has been selected to become var1 and so on. Seems more complex than it needs to be.


if(document.getElementById("pdf_line_0_1_1").value > '') { var var1 = document.getElementById("pdf_line_0_1_1").value } 
if (var1 > ''){ var var2 = document.getElementById("pdf_line_0_1_2").value } else { var var1 =  document.getElementById("pdf_line_0_1_3").value }



Any help or insight would be appreciated,

Steve
Was This Post Helpful? 0
  • +
  • -

#4 skirkpatrick  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 62
  • Joined: 18-February 08

Re: How to grab values that are greater > '' and make new vari

Posted 16 May 2012 - 10:25 AM

OK - now I kind-of get it - I can use an array to capture the values and then format the array values but I am stuck again.

output = [];
for (var i = 1; i <= 13; i++ ) {  
 output[i] =  "document.getElementById('pdf_line_0_1_" + i + "').value";
   document.write(output[i] + "\n")
} 



My elements are incremented like this:

document.getElementById('pdf_line_0_1_1').value
document.getElementById('pdf_line_0_1_2').value
document.getElementById('pdf_line_0_1_3').value

so the line
output[i] =  "document.getElementById('pdf_line_0_1_" + i + "').value";



gives me the element name and not the value

How can I get the value

Steve
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1