Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why I can't use onchange atribute with select field? #4135

Closed
Jimmi08 opened this issue Apr 21, 2020 · 4 comments
Closed

Why I can't use onchange atribute with select field? #4135

Jimmi08 opened this issue Apr 21, 2020 · 4 comments
Labels
type: question An ask about behavior that is not found documented anywhere

Comments

@Jimmi08
Copy link
Contributor

Jimmi08 commented Apr 21, 2020

Question

Tested with the select field.
V1 code:
$cl.= form::form_select_open("category_form", "onchange=\"top.window.location = '".e_PLUGIN."SP_FormBuilder/admin/formbuilder.php?'+this.options[this.selectedIndex].value;\"");

Because this code:

foreach (array_keys($user_options) as $key)
	{
	if(!isset($def_options[$key]) && substr($key,0,5)!='data-') unset($user_options[$key]); // data-xxxx exempt //remove it?
	}
if(substr($option,0,5) =='data-')
{
	$ret .= " ".$option."='{$optval}'";	
}

I can't update that code with e_form with
$cl.= $frm->select_open("category_form", array('onchange'=>$onchange) );

How to do it now? Thanks

@Jimmi08 Jimmi08 added the type: question An ask about behavior that is not found documented anywhere label Apr 21, 2020
@CaMer0n
Copy link
Member

CaMer0n commented Apr 22, 2020

@Jimmi08
Copy link
Contributor Author

Jimmi08 commented Apr 22, 2020

https://stackoverflow.com/questions/11179406/jquery-get-value-of-select-onchange

Sorry, I didn't get what you were trying to say.

I have working code with the latest e107 (jquery, PHP 7.2...) the only problem is that it uses old form class, not a new one e_form. And because I wanted to update it, I found that it is not possible now.

Why do you limit user attributes only for "data-"? - I suppose you probably need this for Admin UI,
There is already the option for this. There are default attributes and user attributes.
Why they are limited only for name "data-" ?

Thanks

@CaMer0n
Copy link
Member

CaMer0n commented Apr 28, 2020

@Jimmi08 We have jQuery built in, so better to use it. That link provides the modern solution to solve your problem.

@Jimmi08
Copy link
Contributor Author

Jimmi08 commented Apr 28, 2020

So you need a separated javascript code. Just great, Thanks

@Jimmi08 Jimmi08 closed this as completed Apr 28, 2020
CaMer0n added a commit that referenced this issue Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question An ask about behavior that is not found documented anywhere
Projects
None yet
Development

No branches or pull requests

2 participants