File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript Conditional Operator(i.e., ?)

 
Shyam Kasthala
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Can any one tell me how to use conditional operator(?) in javascript in window.location.Can any one tell me what this means : -

window.location="project.jsp?module="+document.frm.module.options[document.frm.module.selectedIndex].text;

I have 4 combo boxes where the second and third combo box values depend on the first combo box value and third combo box value depend on the second.I am able to write the code for the first half but struggling to write for the second half.

function getpname()
{
window.location="project.jsp?pid="+document.frm.pid.options[document.frm.pid.selectedIndex].text;
}
The above code is running fine.
But there is some problem in the following code that i am unable to understand.

function getsname()
{window.location="project.jsp?module="+document.frm.module.options[document.frm.module.selectedIndex].text;
}
All the combo boxes are in the same jsp page.
Please tell me how to use the conditional operator(?) with window.location.
Please solve this.Thank you.
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello kasthala
Can any one tell me how to use conditional operator(?) in javascript in window.location.Can any one tell me what this means : -

window.location="project.jsp?module="+document.frm.module.options[document.frm.module.selectedIndex].text;

i am not sure if i understanding you.
In the previous statement there arent any condicional operator.
It's an URL.

Regards
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"project.jsp?module="+document.frm.module.options[document.frm.module.selectedIndex].text;


The ? is not a conditional operator(i guess, you are confusing it with Java's conditional operator). Anything following the ? in the query string represents the parameter key-values that are being passed as part of the URL. In this case, a parameter with the name 'module' is being passed a value evaluated out of the expression document.frm.module.options[document.frm.module.selectedIndex].text.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jaikiran pai:

The ? is not a conditional operator


Yes, it is. Just not in this case because it's part of a string.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic