Jump to content

Function question


amg182

Recommended Posts

What do you mean by "I am trying to call variables inside a function".

 

In the code you posted above you are passing two values into the function as two parameters. Then, based upon the value of the first parameter, you are modifying the value of the 2nd parameter. And, that's it. You don't apss anything back from the function.

 

What exactly are you trying to accomplish with his function. It looks like you are using it to determine if a form field is disabled or not, but I'd be interested in seeing how you plan to use it.

Link to comment
https://forums.phpfreaks.com/topic/246312-function-question/#findComment-1264933
Share on other sites

thanks for replies.

 

I have a form containg up to 13 select fields(comboboxes). I am writing an if statement to say if  the comboboxs contains a value then disable it, otherwise leave it enabled.

 

Here is the actual code i am working with:

 

if ( $select1 != "" ) {
   $cond="disabled";
}
else {
  $cond='onChange="filters.submit();"';
}

.....
<form name="filters" id="filters" action="index.php?" method="post">

<td><Select name='select1' id=" <?php echo $cond; ?>>
<option value.....

 

Rather than write this if statement 13 times, i thought i would use a function instead. Sorry i over complicated things earlier, thought i would strip the code down to make it easier to interpret.(Done the opposite probably)

 

 

Link to comment
https://forums.phpfreaks.com/topic/246312-function-question/#findComment-1264945
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.